request-log-analyzer 1.3.6 → 1.3.7
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.
- data/lib/request_log_analyzer.rb +1 -1
- data/lib/request_log_analyzer/file_format/merb.rb +3 -2
- data/lib/request_log_analyzer/file_format/rails.rb +5 -5
- data/lib/request_log_analyzer/request.rb +0 -4
- data/lib/request_log_analyzer/source/log_parser.rb +10 -5
- data/request-log-analyzer.gemspec +2 -2
- data/spec/integration/command_line_usage_spec.rb +6 -0
- metadata +2 -2
data/lib/request_log_analyzer.rb
CHANGED
@@ -11,7 +11,7 @@ module RequestLogAnalyzer
|
|
11
11
|
|
12
12
|
# The current version of request-log-analyzer.
|
13
13
|
# This will be diplayed in output reports etc.
|
14
|
-
VERSION = "1.3.
|
14
|
+
VERSION = "1.3.7"
|
15
15
|
|
16
16
|
# Loads constants in the RequestLogAnalyzer namespace using self.load_default_class_file(base, const)
|
17
17
|
# <tt>const</tt>:: The constant that is not yet loaded in the RequestLogAnalyzer namespace. This should be passed as a string or symbol.
|
@@ -8,7 +8,7 @@ module RequestLogAnalyzer::FileFormat
|
|
8
8
|
# ~ Started request handling: Fri Aug 29 11:10:23 +0200 2008
|
9
9
|
line_definition :started do |line|
|
10
10
|
line.header = true
|
11
|
-
|
11
|
+
line.teaser = /Started request handling\:/
|
12
12
|
line.regexp = /Started request handling\:\ (.+)/
|
13
13
|
line.captures << { :name => :timestamp, :type => :timestamp }
|
14
14
|
end
|
@@ -16,7 +16,7 @@ module RequestLogAnalyzer::FileFormat
|
|
16
16
|
# ~ Params: {"action"=>"create", "controller"=>"session"}
|
17
17
|
# ~ Params: {"_method"=>"delete", "authenticity_token"=>"[FILTERED]", "action"=>"d}
|
18
18
|
line_definition :params do |line|
|
19
|
-
|
19
|
+
line.teaser = /Params\:\ /
|
20
20
|
line.regexp = /Params\:\ (\{.+\})/
|
21
21
|
line.captures << { :name => :params, :type => :eval, :provides => {
|
22
22
|
:namespace => :string, :controller => :string, :action => :string, :format => :string, :method => :string } }
|
@@ -25,6 +25,7 @@ module RequestLogAnalyzer::FileFormat
|
|
25
25
|
# ~ {:dispatch_time=>0.006117, :after_filters_time=>6.1e-05, :before_filters_time=>0.000712, :action_time=>0.005833}
|
26
26
|
line_definition :completed do |line|
|
27
27
|
line.footer = true
|
28
|
+
# line.teaser = Regexp.new(Regexp.quote('~ {:'))
|
28
29
|
line.regexp = /(\{.*\:dispatch_time\s*=>\s*\d+\.\d+.*\})/
|
29
30
|
line.captures << { :name => :times_hash, :type => :eval, :provides => {
|
30
31
|
:dispatch_time => :duration, :after_filters_time => :duration,
|
@@ -5,7 +5,7 @@ module RequestLogAnalyzer::FileFormat
|
|
5
5
|
# Processing EmployeeController#index (for 123.123.123.123 at 2008-07-13 06:00:00) [GET]
|
6
6
|
line_definition :processing do |line|
|
7
7
|
line.header = true # this line is the first log line for a request
|
8
|
-
|
8
|
+
line.teaser = /Processing /
|
9
9
|
line.regexp = /Processing ((?:\w+::)?\w+)#(\w+)(?: to (\w+))? \(for (\d+\.\d+\.\d+\.\d+) at (\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d)\) \[([A-Z]+)\]/
|
10
10
|
line.captures << { :name => :controller, :type => :string } \
|
11
11
|
<< { :name => :action, :type => :string } \
|
@@ -15,9 +15,9 @@ module RequestLogAnalyzer::FileFormat
|
|
15
15
|
<< { :name => :method, :type => :string }
|
16
16
|
end
|
17
17
|
|
18
|
-
# Filter chain halted as [#<ActionController::Caching::Actions::ActionCacheFilter:0x2a999ad620 @check=nil, @options={:store_options=>{}, :layout=>nil, :cache_path=>#<Proc:0x0000002a999b8890@/app/controllers/cached_controller.rb:8>}>] rendered_or_redirected.
|
18
|
+
# Filter chain halted as [#<ActionController::Caching::Actions::ActionCacheFilter:0x2a999ad620 @check=nil, @options={:store_options=>{}, :layout=>nil, :cache_path=>#<Proc:0x0000002a999b8890@/app/controllers/cached_controller.rb:8>}>] rendered_or_redirected.
|
19
19
|
line_definition :cache_hit do |line|
|
20
|
-
line.regexp = /Filter chain halted as \[\#<ActionController::Caching::Actions::ActionCacheFilter
|
20
|
+
line.regexp = /Filter chain halted as \[\#<ActionController::Caching::Actions::ActionCacheFilter/
|
21
21
|
end
|
22
22
|
|
23
23
|
# RuntimeError (Cannot destroy employee): /app/models/employee.rb:198:in `before_destroy'
|
@@ -46,7 +46,7 @@ module RequestLogAnalyzer::FileFormat
|
|
46
46
|
line_definition :completed do |line|
|
47
47
|
|
48
48
|
line.footer = true
|
49
|
-
|
49
|
+
line.teaser = /Completed in /
|
50
50
|
line.regexp = Regexp.new("(?:#{RAILS_21_COMPLETED}|#{RAILS_22_COMPLETED})")
|
51
51
|
|
52
52
|
line.captures << { :name => :duration, :type => :duration, :unit => :sec } \
|
@@ -91,7 +91,7 @@ module RequestLogAnalyzer::FileFormat
|
|
91
91
|
|
92
92
|
# Do not use DateTime.parse
|
93
93
|
def convert_timestamp(value, definition)
|
94
|
-
value.gsub(/[^0-9]/, '')[0...14].to_i
|
94
|
+
value.gsub(/[^0-9]/, '')[0...14].to_i
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -9,10 +9,6 @@ module RequestLogAnalyzer
|
|
9
9
|
# Request#every(field_name) returns all values corresponding to the given field name as array.
|
10
10
|
class Request
|
11
11
|
|
12
|
-
def self.inherited(klass)
|
13
|
-
# klass.send(:include, Converters)
|
14
|
-
end
|
15
|
-
|
16
12
|
module Converters
|
17
13
|
|
18
14
|
# Default converter function, which converts the parsed strings to a native Ruby type
|
@@ -94,21 +94,26 @@ module RequestLogAnalyzer::Source
|
|
94
94
|
# <tt>options</tt>:: A Hash of options that will be pased to parse_io.
|
95
95
|
def parse_file(file, options = {}, &block)
|
96
96
|
|
97
|
-
@progress_handler = @dormant_progress_handler
|
98
97
|
@current_source = File.expand_path(file)
|
99
|
-
@progress_handler.call(:started, file) if @progress_handler
|
100
98
|
@source_changes_handler.call(:started, @current_source) if @source_changes_handler
|
101
99
|
|
102
100
|
if decompress_file?(file).empty?
|
101
|
+
|
102
|
+
@progress_handler = @dormant_progress_handler
|
103
|
+
@progress_handler.call(:started, file) if @progress_handler
|
104
|
+
|
103
105
|
File.open(file, 'r') { |f| parse_io(f, options, &block) }
|
106
|
+
|
107
|
+
@progress_handler.call(:finished, file) if @progress_handler
|
108
|
+
@progress_handler = nil
|
104
109
|
else
|
105
110
|
IO.popen(decompress_file?(file), 'r') { |f| parse_io(f, options, &block) }
|
106
111
|
end
|
107
112
|
|
108
113
|
@source_changes_handler.call(:finished, @current_source) if @source_changes_handler
|
109
|
-
|
114
|
+
|
110
115
|
@current_source = nil
|
111
|
-
|
116
|
+
|
112
117
|
end
|
113
118
|
|
114
119
|
# Parses an IO stream. It will simply call parse_io. This function does not support progress updates
|
@@ -134,7 +139,7 @@ module RequestLogAnalyzer::Source
|
|
134
139
|
def parse_io(io, options = {}, &block) # :yields: request
|
135
140
|
@current_lineno = 1
|
136
141
|
while line = io.gets
|
137
|
-
@progress_handler.call(:progress, io.pos) if @progress_handler &&
|
142
|
+
@progress_handler.call(:progress, io.pos) if @progress_handler && @current_lineno % 255 == 0
|
138
143
|
|
139
144
|
if request_data = file_format.parse_line(line) { |wt, message| warn(wt, message) }
|
140
145
|
@parsed_lines += 1
|
@@ -15,6 +15,12 @@ describe RequestLogAnalyzer, 'running from command line' do
|
|
15
15
|
output.any? { |line| /^Parsed requests\:\s*4\s/ =~ line }.should be_true
|
16
16
|
end
|
17
17
|
|
18
|
+
it "should find 2 requests when parsing a compressed file" do
|
19
|
+
output = run("#{log_fixture(:decompression, :tgz)}")
|
20
|
+
output.any? { |line| /^Parsed requests\:\s*2\s/ =~ line }.should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
|
18
24
|
it "should skip 1 requests with a --select option" do
|
19
25
|
output = run("#{log_fixture(:rails_1x)} --select controller PeopleController")
|
20
26
|
output.any? { |line| /^Skipped requests\:\s*1\s/ =~ line }.should be_true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request-log-analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-09-
|
13
|
+
date: 2009-09-22 00:00:00 +02:00
|
14
14
|
default_executable: request-log-analyzer
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|