rawk_log 2.4.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +3 -1
- data/lib/rawk_log/command.rb +67 -59
- data/lib/rawk_log/patch_logger.rb +11 -7
- data/lib/rawk_log/stat.rb +5 -5
- data/lib/rawk_log/stat_hash.rb +5 -5
- data/lib/rawk_log/version.rb +1 -1
- data/test/patch_logger_test.rb +129 -0
- metadata +11 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 39538612fe84a0c631302ff4ca0cf0b3be85c40a
|
4
|
+
data.tar.gz: 7ef3b46678d22a04f28733bb58226a48a8393e8f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ad3d8d1550056b4049b0db70d8f0a7c5501b2dfc22ba684d8fecdbb69ccae34a1829ebeda520cdd38ba73a05462b4aa3e08790bd4ad40f0dde36d92dd40b1e1c
|
7
|
+
data.tar.gz: 90f9bb3ced20d8b6460bd421b35a1e4724e1a0fc394a2fc55041ee7a6fc552e0f0af0b45314854edee5e20450031408b15949e000275391966f0cc3894b400f0
|
data/README.md
CHANGED
@@ -6,6 +6,8 @@ This tool gives statistics for Ruby on Rails log files. The times for each reque
|
|
6
6
|
|
7
7
|
[](https://travis-ci.org/ianheggie/rawk_log)
|
8
8
|
|
9
|
+
Supports Rails versions 2.3, 3.0, 3.1, 3.2 and 4.0
|
10
|
+
|
9
11
|
## Installation
|
10
12
|
|
11
13
|
Add this line to your application's Gemfile:
|
@@ -57,7 +59,7 @@ rawk_log usage:
|
|
57
59
|
-y <date> Date (inclusive) to stop parsing in 'yyyy-mm-dd' format.
|
58
60
|
|
59
61
|
Example usage:
|
60
|
-
rawk_log log/production.log
|
62
|
+
rawk_log -f log/production.log
|
61
63
|
|
62
64
|
## Contributing
|
63
65
|
|
data/lib/rawk_log/command.rb
CHANGED
@@ -6,32 +6,33 @@ require "rawk_log/version"
|
|
6
6
|
module RawkLog
|
7
7
|
class Command
|
8
8
|
HELP = "\nRAWK_LOG - Rail's Analyzer With Klass for log files v#{VERSION}\n"+
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
9
|
+
"Created by Chris Hobbs of Spongecell, LLC, updated by Ian Heggie and others\n"+
|
10
|
+
"This tool gives statistics for Ruby on Rails log files. The times for each request are grouped and totals are displayed. "+
|
11
|
+
"If process ids are present in the log files then requests are sorted by ActionController actions otherwise requests are grouped by url. "+
|
12
|
+
"By default total request times are used for comparison but database time or render time can be used by specifying the correct flag. "+
|
13
|
+
"The log file is read from standard input unless the -f flag is specified.\n\n"+
|
14
|
+
"The options are as follows:\n\n"+
|
15
|
+
" -? Display this help.\n\n"+
|
16
|
+
" -d Use DB times as data points. These times are found after 'DB:' in the log file. This overrides the default behavior of using the total request time.\n\n"+
|
17
|
+
" -f <filename> Use the specified file instead of standard input.\n\n"+
|
18
|
+
" -h Display this help.\n\n"+
|
19
|
+
" -r Use Render times as data points. These times are found after 'Rendering:' in the log file. This overrides the default behavior of using the total request time.\n\n"+
|
20
|
+
" -s <count> Display <count> results in each group of data.\n\n"+
|
21
|
+
" -t Self Test\n\n"+
|
22
|
+
" -v verbose mode (outputs a dot each 1000 lines).\n\n"+
|
23
|
+
" -u Group requests by url instead of the controller and action used. This is the default behavior if there is are no process ids in the log file.\n\n"+
|
24
|
+
" -w <count> Display the top <count> worst requests.\n\n"+
|
25
|
+
" -x <date> Date (inclusive) to start parsing in 'yyyy-mm-dd' format.\n\n"+
|
26
|
+
" -y <date> Date (inclusive) to stop parsing in 'yyyy-mm-dd' format.\n\n"+
|
27
|
+
"To install the rawk_log command, add this to application's Gemfile and run bundle:\n\n"+
|
28
|
+
" gem 'rawk_log'\n\n"+
|
29
|
+
"To enable reporting by controler#action add the following to the end of config/environment.rb:\n\n"+
|
30
|
+
" require 'rawk_log/patch_logger'\n\n"+
|
31
|
+
"This software is Beerware, if you like it, buy yourself a beer or something nicer ;)\n"+
|
32
|
+
"\n"+
|
33
|
+
"Example usage:\n"+
|
34
|
+
" rawk_log -f log/production.log\n"
|
35
|
+
|
35
36
|
def initialize(args)
|
36
37
|
@start_time = Time.now
|
37
38
|
build_arg_hash(args)
|
@@ -44,7 +45,9 @@ module RawkLog
|
|
44
45
|
Stat.test
|
45
46
|
else
|
46
47
|
init_args
|
48
|
+
puts "Building stats" if @debug
|
47
49
|
build_stats
|
50
|
+
puts "\nPrinting stats" if @debug
|
48
51
|
print_stats
|
49
52
|
end
|
50
53
|
end
|
@@ -54,7 +57,7 @@ module RawkLog
|
|
54
57
|
last_key=nil
|
55
58
|
for a in args
|
56
59
|
if a.index("-")==0 && a.length>1
|
57
|
-
a[1,1000].scan(/[a-z]|\?/).each {|c| @arg_hash[last_key=c]=nil}
|
60
|
+
a[1, 1000].scan(/[a-z]|\?/).each { |c| @arg_hash[last_key=c]=nil }
|
58
61
|
@arg_hash[last_key] = a[/\d+/] if last_key
|
59
62
|
elsif a.index("-")!=0 && last_key
|
60
63
|
@arg_hash[last_key] = a
|
@@ -72,6 +75,7 @@ module RawkLog
|
|
72
75
|
@input = $stdin
|
73
76
|
keys = @arg_hash.keys
|
74
77
|
@force_url_use = keys.include?("u")
|
78
|
+
@verbose = keys.include?("v")
|
75
79
|
@db_time = keys.include?("d")
|
76
80
|
@render_time = keys.include?("r")
|
77
81
|
@worst_request_length=(@arg_hash["w"].to_i) if @arg_hash["w"]
|
@@ -80,15 +84,15 @@ module RawkLog
|
|
80
84
|
@from =(Date.parse(@arg_hash["x"])) if @arg_hash["x"]
|
81
85
|
@to =(Date.parse(@arg_hash["y"])) if @arg_hash["y"]
|
82
86
|
end
|
83
|
-
|
87
|
+
|
84
88
|
def is_id?(word)
|
85
89
|
word =~ /^((\d+(-.*)?)|([\dA-F\-]{36}))$/i
|
86
90
|
end
|
87
|
-
|
91
|
+
|
88
92
|
def is_filename?(word)
|
89
93
|
word =~ /\.[a-z]{1,5}\d?$/i
|
90
94
|
end
|
91
|
-
|
95
|
+
|
92
96
|
def build_stats
|
93
97
|
@stat_hash = StatHash.new
|
94
98
|
@total_stat = Stat.new("All Requests")
|
@@ -96,8 +100,11 @@ module RawkLog
|
|
96
100
|
last_actions = Hash.new
|
97
101
|
last_date = Date.civil
|
98
102
|
line_no = 1
|
103
|
+
$stdout.flush
|
99
104
|
while @input.gets
|
100
105
|
line_no += 1
|
106
|
+
$stdout.write "." if @verbose && (line_no % 1000) == 0
|
107
|
+
next unless $_ =~ /^[PSC]/
|
101
108
|
if $_.index("Processing by ")==0
|
102
109
|
action = $_.split[2]
|
103
110
|
pid = $_[/\(pid\:\d+\)/]
|
@@ -124,10 +131,10 @@ module RawkLog
|
|
124
131
|
pid = $_[/\(pid\:\d+\)/] if !@force_url_use
|
125
132
|
key = last_actions[pid] if pid
|
126
133
|
time = 0.0
|
127
|
-
|
134
|
+
|
128
135
|
# Old: Completed in 0.45141 (2 reqs/sec) | Rendering: 0.25965 (57%) | DB: 0.06300 (13%) | 200 OK [http://localhost/jury/proposal/312]
|
129
136
|
# New: Completed in 100ms (View: 40, DB: 4)
|
130
|
-
|
137
|
+
|
131
138
|
if @db_time
|
132
139
|
time_string = $_[/DB: \d+(\.\d+)?[ms]*/]
|
133
140
|
elsif @render_time
|
@@ -149,22 +156,22 @@ module RawkLog
|
|
149
156
|
uri = $_[/\[[^\]]+\]/]
|
150
157
|
if uri and uri != ''
|
151
158
|
key = if @force_url_use
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
159
|
+
(uri.gsub(/\S+\/\/(\w|\.)*/, ''))[/[^\?\]]*/]
|
160
|
+
else
|
161
|
+
data = uri.gsub(/\S+\/\/(\w|\.)*/, '')
|
162
|
+
s = data.gsub(/(\?.*)|\]$/, '').split("/")
|
156
163
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
164
|
+
keywords = s.inject([]) do |keywords, word|
|
165
|
+
if is_id?(word.to_s)
|
166
|
+
keywords << '{ID}'
|
167
|
+
elsif !word.to_s.empty?
|
168
|
+
keywords << word.to_s
|
169
|
+
end
|
170
|
+
keywords
|
171
|
+
end
|
172
|
+
keywords[-1] = '{filename}' if !keywords.empty? and is_filename?(keywords[-1])
|
173
|
+
k = "/#{keywords.join("/")}"
|
174
|
+
end
|
168
175
|
end
|
169
176
|
end
|
170
177
|
|
@@ -174,15 +181,16 @@ module RawkLog
|
|
174
181
|
end
|
175
182
|
|
176
183
|
if (@from.nil? or @from <= date) and (@to.nil? or @to >= date) # date criteria here
|
177
|
-
@stat_hash.add(key,time)
|
184
|
+
@stat_hash.add(key, time)
|
178
185
|
@total_stat.add(time)
|
179
186
|
if @worst_requests.length<@worst_request_length || @worst_requests[@worst_request_length-1][0]<time
|
180
|
-
@worst_requests << [time
|
181
|
-
@worst_requests.sort! {|a,b| (b[0] && a[0]) ? b[0]<=>a[0] : 0}
|
182
|
-
@worst_requests=@worst_requests[0
|
187
|
+
@worst_requests << [time, %Q(#{datetime} #{$_})]
|
188
|
+
@worst_requests.sort! { |a, b| (b[0] && a[0]) ? b[0]<=>a[0] : 0 }
|
189
|
+
@worst_requests=@worst_requests[0, @worst_request_length]
|
183
190
|
end
|
184
191
|
end
|
185
192
|
end
|
193
|
+
$stdout.flush
|
186
194
|
end
|
187
195
|
|
188
196
|
def print_stats
|
@@ -199,21 +207,21 @@ module RawkLog
|
|
199
207
|
puts @total_stat.to_s(label_size)
|
200
208
|
if not @stat_hash.empty?
|
201
209
|
puts "\n\nTop #{@sorted_limit} by Count"
|
202
|
-
@stat_hash.print(:sort_by=>"count"
|
210
|
+
@stat_hash.print(:sort_by => "count", :limit => @sorted_limit, :ascending => false)
|
203
211
|
puts "\n\nTop #{@sorted_limit} by Sum of Time"
|
204
|
-
@stat_hash.print(:sort_by=>"sum"
|
212
|
+
@stat_hash.print(:sort_by => "sum", :limit => @sorted_limit, :ascending => false)
|
205
213
|
puts "\n\nTop #{@sorted_limit} Greatest Max"
|
206
|
-
@stat_hash.print(:sort_by=>"max"
|
214
|
+
@stat_hash.print(:sort_by => "max", :limit => @sorted_limit, :ascending => false)
|
207
215
|
puts "\n\nTop #{@sorted_limit} Greatest Median"
|
208
|
-
@stat_hash.print(:sort_by=>"median"
|
216
|
+
@stat_hash.print(:sort_by => "median", :limit => @sorted_limit, :ascending => false)
|
209
217
|
puts "\n\nTop #{@sorted_limit} Greatest Avg"
|
210
|
-
@stat_hash.print(:sort_by=>"average"
|
218
|
+
@stat_hash.print(:sort_by => "average", :limit => @sorted_limit, :ascending => false)
|
211
219
|
puts "\n\nTop #{@sorted_limit} Least Min"
|
212
|
-
@stat_hash.print(:sort_by=>"min"
|
220
|
+
@stat_hash.print(:sort_by => "min", :limit => @sorted_limit)
|
213
221
|
puts "\n\nTop #{@sorted_limit} Greatest Standard Deviation"
|
214
|
-
@stat_hash.print(:sort_by=>"standard_deviation"
|
222
|
+
@stat_hash.print(:sort_by => "standard_deviation", :limit => @sorted_limit, :ascending => false)
|
215
223
|
puts "\n\nTop #{@worst_request_length} Worst Requests"
|
216
|
-
@worst_requests.each {|w| puts w[1].to_s}
|
224
|
+
@worst_requests.each { |w| puts w[1].to_s }
|
217
225
|
end
|
218
226
|
puts "\n\nCompleted report in %1.2f minutes" % ((Time.now.to_i-@start_time.to_i)/60.0)
|
219
227
|
end
|
@@ -2,8 +2,11 @@ if defined?(Logger)
|
|
2
2
|
|
3
3
|
class Logger
|
4
4
|
def format_message(severity, timestamp, progname, msg)
|
5
|
-
|
6
|
-
|
5
|
+
# If a newline is necessary then create a new message ending with a newline.
|
6
|
+
# Ensures that the original message is not mutated.
|
7
|
+
msg = "#{msg}\n" unless msg[-1,1] == "\n"
|
8
|
+
if msg !~ /\(pid\:/
|
9
|
+
msg.gsub(/(\S.)$/, "\\1 (pid:#{$$})")
|
7
10
|
else
|
8
11
|
msg
|
9
12
|
end
|
@@ -19,7 +22,7 @@ end
|
|
19
22
|
if defined?(ActiveSupport::BufferedLogger)
|
20
23
|
|
21
24
|
module ActiveSupport
|
22
|
-
|
25
|
+
|
23
26
|
class BufferedLogger
|
24
27
|
|
25
28
|
def add_with_pid(severity, message = nil, progname = nil, &block)
|
@@ -27,16 +30,17 @@ if defined?(ActiveSupport::BufferedLogger)
|
|
27
30
|
message = (message || (block && block.call) || progname).to_s
|
28
31
|
# If a newline is necessary then create a new message ending with a newline.
|
29
32
|
# Ensures that the original message is not mutated.
|
30
|
-
message = "#{message}\n" unless message[-1] ==
|
31
|
-
if message !~
|
32
|
-
message.gsub(
|
33
|
+
message = "#{message}\n" unless message[-1,1] == "\n"
|
34
|
+
if message !~ /\(pid\:/
|
35
|
+
message.gsub(/(\S.)$/, "\\1 (pid:#{$$})")
|
33
36
|
else
|
34
37
|
message
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
|
-
|
42
|
+
alias_method :add_without_pid, :add
|
43
|
+
alias_method :add, :add_with_pid
|
40
44
|
|
41
45
|
end
|
42
46
|
end
|
data/lib/rawk_log/stat.rb
CHANGED
@@ -67,14 +67,14 @@ module RawkLog
|
|
67
67
|
|
68
68
|
def standard_deviation
|
69
69
|
return 0 if @count<=1
|
70
|
-
Math.sqrt((@sum_squares - (@sum*@sum/@count))/ (@count)
|
70
|
+
Math.sqrt((@sum_squares - (@sum*@sum/@count))/ (@count))
|
71
71
|
end
|
72
72
|
|
73
73
|
def to_s(label_size = DEFAULT_LABEL_SIZE)
|
74
74
|
if count > 0
|
75
|
-
sprintf("%*s %6d %9.2f %7d %7d %7d %7d %7d"
|
75
|
+
sprintf("%*s %6d %9.2f %7d %7d %7d %7d %7d", -label_size, key, count, sum, max*1000.0, median*1000.0, average*1000.0, min*1000.0, standard_deviation*1000.0)
|
76
76
|
else
|
77
|
-
|
77
|
+
sprintf("%*s %6d", -label_size, key, 0)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -84,11 +84,11 @@ module RawkLog
|
|
84
84
|
stat.add(6)
|
85
85
|
stat.add(8)
|
86
86
|
stat.add(9)
|
87
|
-
results = [
|
87
|
+
results = [7==stat.median ? "median Success" : "median Failure"]
|
88
88
|
results <<= (7==stat.average ? "average Success" : "average Failure")
|
89
89
|
results <<= (158==(stat.standard_deviation*100).round ? "std Success" : "std Failure")
|
90
90
|
puts results.join("\n")
|
91
|
-
exit (results.select{|m| m =~ /Failure/}.size)
|
91
|
+
exit (results.select { |m| m =~ /Failure/ }.size)
|
92
92
|
end
|
93
93
|
|
94
94
|
end
|
data/lib/rawk_log/stat_hash.rb
CHANGED
@@ -11,16 +11,16 @@ module RawkLog
|
|
11
11
|
@stats.empty?
|
12
12
|
end
|
13
13
|
|
14
|
-
def add(key,time)
|
14
|
+
def add(key, time)
|
15
15
|
stat = @stats[key] || (@stats[key] = RawkLog::Stat.new(key))
|
16
16
|
stat.add(time)
|
17
17
|
end
|
18
18
|
|
19
|
-
def print(args={:sort_by=>'key'
|
19
|
+
def print(args={:sort_by => 'key', :ascending => true, :limit => nil})
|
20
20
|
values = @stats.values
|
21
21
|
return Stat::DEFAULT_LABEL_SIZE if values.empty?
|
22
22
|
order = (args[:ascending] || args[:ascending].nil?) ? 1 : -1
|
23
|
-
values.sort! {|a,b|
|
23
|
+
values.sort! { |a, b|
|
24
24
|
as = a.send(args[:sort_by])
|
25
25
|
bs = b.send(args[:sort_by])
|
26
26
|
(as && bs) ? order*(as<=>bs) : 0
|
@@ -28,9 +28,9 @@ module RawkLog
|
|
28
28
|
#values.sort! {|a,b| a.key<=>b.key}
|
29
29
|
limit = args[:limit]
|
30
30
|
if limit
|
31
|
-
values = values[0,limit]
|
31
|
+
values = values[0, limit]
|
32
32
|
end
|
33
|
-
@label_size = values.collect{|v| v.key.size }.max
|
33
|
+
@label_size = values.collect { |v| v.key.size }.max
|
34
34
|
@label_size = Stat::DEFAULT_LABEL_SIZE if @label_size < Stat::DEFAULT_LABEL_SIZE
|
35
35
|
puts values[0].header(@label_size)
|
36
36
|
for stat in values
|
data/lib/rawk_log/version.rb
CHANGED
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class Logger
|
4
|
+
|
5
|
+
def initialize(level)
|
6
|
+
# don't care
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
module ActiveSupport
|
13
|
+
|
14
|
+
class BufferedLogger
|
15
|
+
|
16
|
+
def initialize(level)
|
17
|
+
# don't care
|
18
|
+
end
|
19
|
+
|
20
|
+
# fake to get result of block back
|
21
|
+
def add(severity, message = nil, progname = nil, &block)
|
22
|
+
(block && block.call) || message
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#require "rawk_log/patch_logger"
|
29
|
+
|
30
|
+
require File.dirname(__FILE__) + '/../lib/rawk_log/patch_logger'
|
31
|
+
|
32
|
+
class BufferedLoggerTest < Test::Unit::TestCase
|
33
|
+
|
34
|
+
def setup
|
35
|
+
@logger = ActiveSupport::BufferedLogger.new(nil)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_loaded_constant_is_true
|
39
|
+
assert_equal(true, RawkLog::PATCHED_BUFFERED_LOGGER)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_leaves_blank_lines_alone
|
43
|
+
msg = @logger.add(nil, "\n\n")
|
44
|
+
assert_equal("\n\n", msg)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_adds_only_newline_to_empty_string
|
48
|
+
msg = @logger.add(nil, "")
|
49
|
+
assert_equal("\n", msg)
|
50
|
+
msg = @logger.add(nil, msg)
|
51
|
+
assert_equal("\n", msg)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_adds_pid_to_line
|
55
|
+
msg = @logger.add(nil, "some message")
|
56
|
+
assert_match(/^some message \(pid:\d+\)\n$/m, msg)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_adds_pid_to_line_only_once
|
60
|
+
msg = @logger.add(nil, "some message")
|
61
|
+
msg = @logger.add(nil, msg)
|
62
|
+
assert_match(/^some message \(pid:\d+\)\n$/m, msg)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_adds_pid_to_all_lines
|
66
|
+
msg = @logger.add(nil, "some message\nanother message")
|
67
|
+
msg = @logger.add(nil, msg)
|
68
|
+
assert_match(/some message \(pid:\d+\)\n/m, msg)
|
69
|
+
assert_match(/another message \(pid:\d+\)\n/m, msg)
|
70
|
+
assert_no_match(/\n *\(pid:/m, msg)
|
71
|
+
|
72
|
+
msg = @logger.add(nil,"some message\nanother message\n\n")
|
73
|
+
msg = @logger.add(nil, msg)
|
74
|
+
assert_match(/some message \(pid:\d+\)\n/m, msg)
|
75
|
+
assert_match(/another message \(pid:\d+\)\n/m, msg)
|
76
|
+
assert_no_match(/\n *\(pid:/m, msg)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
class LoggerTest < Test::Unit::TestCase
|
83
|
+
|
84
|
+
def setup
|
85
|
+
@logger = Logger.new(nil)
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_loaded_constant_is_true
|
89
|
+
assert_equal(true, RawkLog::PATCHED_LOGGER)
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_leaves_blank_lines_alone
|
93
|
+
msg = @logger.format_message(nil, nil, nil, "\n\n")
|
94
|
+
assert_equal("\n\n", msg)
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_adds_only_newline_to_empty_string
|
98
|
+
msg = @logger.format_message(nil, nil, nil, "")
|
99
|
+
assert_equal("\n", msg)
|
100
|
+
msg = @logger.format_message(nil, nil, nil, msg)
|
101
|
+
assert_equal("\n", msg)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_adds_pid_to_line
|
105
|
+
msg = @logger.format_message(nil, nil, nil, "some message")
|
106
|
+
assert_match(/^some message \(pid:\d+\)\n$/m, msg)
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_adds_pid_to_line_only_once
|
110
|
+
msg = @logger.format_message(nil, nil, nil, "some message")
|
111
|
+
msg = @logger.format_message(nil, nil, nil, msg)
|
112
|
+
assert_match(/^some message \(pid:\d+\)\n$/m, msg)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_adds_pid_to_all_lines
|
116
|
+
msg = @logger.format_message(nil, nil, nil, "some message\nanother message")
|
117
|
+
msg = @logger.format_message(nil, nil, nil, msg)
|
118
|
+
assert_match(/some message \(pid:\d+\)\n/m, msg)
|
119
|
+
assert_match(/another message \(pid:\d+\)\n/m, msg)
|
120
|
+
assert_no_match(/\n *\(pid:/m, msg)
|
121
|
+
|
122
|
+
msg = @logger.format_message(nil, nil, nil, "some message\nanother message\n\n")
|
123
|
+
msg = @logger.format_message(nil, nil, nil, msg)
|
124
|
+
assert_match(/some message \(pid:\d+\)\n/m, msg)
|
125
|
+
assert_match(/another message \(pid:\d+\)\n/m, msg)
|
126
|
+
assert_no_match(/\n *\(pid:/m, msg)
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rawk_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
5
|
-
prerelease:
|
4
|
+
version: 2.4.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Chris Hobbs
|
@@ -10,12 +9,11 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2014-
|
12
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: bundler
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
18
|
- - ~>
|
21
19
|
- !ruby/object:Gem::Version
|
@@ -23,7 +21,6 @@ dependencies:
|
|
23
21
|
type: :development
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
25
|
- - ~>
|
29
26
|
- !ruby/object:Gem::Version
|
@@ -31,17 +28,15 @@ dependencies:
|
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: rake
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - '>='
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: '0'
|
39
35
|
type: :development
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - '>='
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: '0'
|
47
42
|
description: RawkLog - RAWK - Rail's Analyzer With Klass for log files
|
@@ -76,6 +71,7 @@ files:
|
|
76
71
|
- test/examples/rails40.log
|
77
72
|
- test/examples/unknown.log
|
78
73
|
- test/mixed_test.rb
|
74
|
+
- test/patch_logger_test.rb
|
79
75
|
- test/rails23_test.rb
|
80
76
|
- test/rails32_test.rb
|
81
77
|
- test/rails40_test.rb
|
@@ -84,27 +80,26 @@ files:
|
|
84
80
|
homepage: https://github.com/ianheggie/rawk_log
|
85
81
|
licenses:
|
86
82
|
- Beerware
|
83
|
+
metadata: {}
|
87
84
|
post_install_message:
|
88
85
|
rdoc_options: []
|
89
86
|
require_paths:
|
90
87
|
- lib
|
91
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
89
|
requirements:
|
94
|
-
- -
|
90
|
+
- - '>='
|
95
91
|
- !ruby/object:Gem::Version
|
96
92
|
version: '0'
|
97
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
94
|
requirements:
|
100
|
-
- -
|
95
|
+
- - '>='
|
101
96
|
- !ruby/object:Gem::Version
|
102
97
|
version: '0'
|
103
98
|
requirements: []
|
104
99
|
rubyforge_project:
|
105
|
-
rubygems_version:
|
100
|
+
rubygems_version: 2.0.14
|
106
101
|
signing_key:
|
107
|
-
specification_version:
|
102
|
+
specification_version: 4
|
108
103
|
summary: This tool gives statistics for Ruby on Rails log files. The times for each
|
109
104
|
request are grouped and totals are displayed. If process ids are present in the
|
110
105
|
log files then requests are sorted by ActionController actions otherwise requests
|
@@ -120,6 +115,7 @@ test_files:
|
|
120
115
|
- test/examples/rails40.log
|
121
116
|
- test/examples/unknown.log
|
122
117
|
- test/mixed_test.rb
|
118
|
+
- test/patch_logger_test.rb
|
123
119
|
- test/rails23_test.rb
|
124
120
|
- test/rails32_test.rb
|
125
121
|
- test/rails40_test.rb
|