rails_log_deinterleaver 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -2
- data/lib/rails_log_deinterleaver/parser.rb +8 -2
- data/lib/rails_log_deinterleaver/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -6,6 +6,7 @@ This gem includes a command line script to parse the interleaved logs and output
|
|
6
6
|
|
7
7
|
Note that I am using syslog/rails 3 so the logs will be in a slightly different format that what rails will output by default in Rails 4. But this library could be easily updated to support both.
|
8
8
|
|
9
|
+
[![Build Status](https://travis-ci.org/mattfawcett/rails_log_deinterleaver.svg?branch=master)](https://travis-ci.org/mattfawcett/rails_log_deinterleaver)
|
9
10
|
|
10
11
|
Install
|
11
12
|
-------
|
@@ -15,5 +16,5 @@ Use
|
|
15
16
|
---
|
16
17
|
rails_log_deinterleaver [options] /path/to/interleaved/railslog.log
|
17
18
|
### possible options
|
18
|
-
-o, --output=x : Where to write the formatted log (if not specified stdout will be used)
|
19
|
-
-b, --backward=x : Start from the bottom of the file, x lines from the end. If not specified, the whole file will be parsed.
|
19
|
+
* -o, --output=x : Where to write the formatted log (if not specified stdout will be used)
|
20
|
+
* -b, --backward=x : Start from the bottom of the file, x lines from the end. If not specified, the whole file will be parsed.
|
@@ -20,7 +20,7 @@ module RailsLogDeinterleaver
|
|
20
20
|
self.ensure_timeouts_logged
|
21
21
|
end
|
22
22
|
|
23
|
-
File.open(@filename) do |log|
|
23
|
+
File.open(@filename, 'r:UTF-8') do |log|
|
24
24
|
log.extend(File::Tail)
|
25
25
|
log.interval = 0.1
|
26
26
|
log.backward(@options[:backward]) if @options[:backward]
|
@@ -31,6 +31,10 @@ module RailsLogDeinterleaver
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def process_line(line)
|
34
|
+
# It is possible for the file to contain UTF-8 byte streams. Get rid of them here.
|
35
|
+
# String#encode does not do anything if source and destination encoding are the same,
|
36
|
+
# so encode to UTF-16 before converting back to UTF-8.
|
37
|
+
line = line.encode('UTF-16', :invalid => :replace, :replace => '').encode('UTF-8')
|
34
38
|
pid = pid_for_line(line)
|
35
39
|
|
36
40
|
if line.match(@options[:start_request_regex])
|
@@ -70,7 +74,9 @@ module RailsLogDeinterleaver
|
|
70
74
|
|
71
75
|
def ensure_timeouts_logged
|
72
76
|
expired_time = Time.now - @options[:request_timeout]
|
73
|
-
@pids
|
77
|
+
# Loop over a clone of @pids because there is a chance that the parent thread
|
78
|
+
# will want to add to the @pids Hash whilst this is running, triggering an exception.
|
79
|
+
@pids.dup.each do |pid, details|
|
74
80
|
if details[:last_seen_at] <= expired_time
|
75
81
|
output_logs_for_pid(pid)
|
76
82
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_log_deinterleaver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-08-
|
12
|
+
date: 2015-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|