request-log-analyzer 1.2.0 → 1.2.1
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/{DESIGN → DESIGN.rdoc} +13 -10
- data/README.rdoc +7 -5
- data/RELEASE_NOTES.rdoc +10 -0
- data/bin/request-log-analyzer +7 -3
- data/lib/cli/tools.rb +2 -2
- data/lib/request_log_analyzer/aggregator/summarizer.rb +51 -2
- data/lib/request_log_analyzer/controller.rb +4 -0
- data/lib/request_log_analyzer/output/fixed_width.rb +36 -1
- data/lib/request_log_analyzer/output/html.rb +20 -2
- data/lib/request_log_analyzer/output.rb +36 -1
- data/lib/request_log_analyzer/request.rb +2 -2
- data/lib/request_log_analyzer/source/database.rb +19 -4
- data/lib/request_log_analyzer/source/log_parser.rb +26 -3
- data/lib/request_log_analyzer/tracker/duration.rb +49 -8
- data/lib/request_log_analyzer/tracker/frequency.rb +30 -7
- data/lib/request_log_analyzer/tracker/hourly_spread.rb +41 -15
- data/lib/request_log_analyzer/tracker/timespan.rb +22 -2
- data/lib/request_log_analyzer/tracker.rb +38 -1
- data/lib/request_log_analyzer.rb +2 -4
- data/spec/fixtures/decompression.log +12 -0
- data/spec/fixtures/decompression.log.bz2 +0 -0
- data/spec/fixtures/decompression.log.gz +0 -0
- data/spec/fixtures/decompression.log.zip +0 -0
- data/spec/fixtures/decompression.tar.gz +0 -0
- data/spec/fixtures/decompression.tgz +0 -0
- data/spec/integration/command_line_usage_spec.rb +14 -14
- data/spec/lib/helper.rb +19 -3
- data/spec/lib/testing_format.rb +1 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/aggregator/summarizer_spec.rb +1 -1
- data/spec/unit/source/log_parser_spec.rb +39 -0
- data/spec/unit/tracker/{tracker_api_test.rb → tracker_api_spec.rb} +7 -1
- data/tasks/github-gem.rake +1 -2
- data/tasks/request_log_analyzer.rake +23 -7
- metadata +16 -29
- data/HACKING +0 -7
data/spec/lib/helper.rb
CHANGED
@@ -2,15 +2,17 @@ module RequestLogAnalyzer::Spec::Helper
|
|
2
2
|
|
3
3
|
include RequestLogAnalyzer::Spec::Mocks
|
4
4
|
|
5
|
-
|
5
|
+
# Create or return a new TestingFormat
|
6
6
|
def testing_format
|
7
7
|
@testing_format ||= TestingFormat.new
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
# Load a log file from the fixture folder
|
11
|
+
def log_fixture(name, extention = "log")
|
12
|
+
File.dirname(__FILE__) + "/../fixtures/#{name}.#{extention}"
|
12
13
|
end
|
13
14
|
|
15
|
+
# Request loopback
|
14
16
|
def request(fields, format = testing_format)
|
15
17
|
if fields.kind_of?(Array)
|
16
18
|
format.request(*fields)
|
@@ -19,6 +21,8 @@ module RequestLogAnalyzer::Spec::Helper
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
24
|
+
# Run a specific command
|
25
|
+
# Used to call request-log-analyzer through binary
|
22
26
|
def run(arguments)
|
23
27
|
binary = "#{File.dirname(__FILE__)}/../../bin/request-log-analyzer"
|
24
28
|
arguments = arguments.join(' ') if arguments.kind_of?(Array)
|
@@ -30,4 +34,16 @@ module RequestLogAnalyzer::Spec::Helper
|
|
30
34
|
$?.exitstatus.should == 0
|
31
35
|
output
|
32
36
|
end
|
37
|
+
|
38
|
+
# Cleanup all temporary files generated by specs
|
39
|
+
def cleanup_temp_files!
|
40
|
+
Dir["#{File.dirname(__FILE__)}/../../tmp/spec.*tmp"].each do |file|
|
41
|
+
File.unlink(file)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Return a filename that can be used as temporary file in specs
|
46
|
+
def temp_output_file(file_type)
|
47
|
+
"#{File.dirname(__FILE__)}/../../tmp/spec.#{file_type}.tmp"
|
48
|
+
end
|
33
49
|
end
|
data/spec/lib/testing_format.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -64,4 +64,43 @@ describe RequestLogAnalyzer::Source::LogParser, :warnings do
|
|
64
64
|
@log_parser.should_not_receive(:handle_request)
|
65
65
|
@log_parser.parse_file(log_fixture(:test_order))
|
66
66
|
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe RequestLogAnalyzer::Source::LogParser, :decompression do
|
70
|
+
include RequestLogAnalyzer::Spec::Helper
|
71
|
+
|
72
|
+
before(:each) do
|
73
|
+
@log_parser = RequestLogAnalyzer::Source::LogParser.new(RequestLogAnalyzer::FileFormat::Rails.new)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should parse a rails gzipped log file" do
|
77
|
+
@log_parser.should_receive(:handle_request).once
|
78
|
+
@log_parser.parse_file(log_fixture(:decompression, "log.gz"))
|
79
|
+
@log_parser.parsed_lines.should > 0
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should parse a rails tar gzipped log folder" do
|
83
|
+
@log_parser.should_receive(:handle_request).twice
|
84
|
+
@log_parser.parse_file(log_fixture(:decompression, "tar.gz"))
|
85
|
+
@log_parser.parsed_lines.should > 1
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should parse a rails tar gzipped log folder" do
|
89
|
+
@log_parser.should_receive(:handle_request).twice
|
90
|
+
@log_parser.parse_file(log_fixture(:decompression, "tgz"))
|
91
|
+
@log_parser.parsed_lines.should > 1
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should parse a rails bz2 zipped log file" do
|
95
|
+
@log_parser.should_receive(:handle_request).once
|
96
|
+
@log_parser.parse_file(log_fixture(:decompression, "log.bz2"))
|
97
|
+
@log_parser.parsed_lines.should > 0
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should parse a rails zipped log file" do
|
101
|
+
@log_parser.should_receive(:handle_request).once
|
102
|
+
@log_parser.parse_file(log_fixture(:decompression, "log.zip"))
|
103
|
+
@log_parser.parsed_lines.should > 0
|
104
|
+
end
|
105
|
+
|
67
106
|
end
|
@@ -10,7 +10,7 @@ describe RequestLogAnalyzer::Tracker::Base, "API test" do
|
|
10
10
|
@summarizer = RequestLogAnalyzer::Aggregator::Summarizer.new(mock_source)
|
11
11
|
@summarizer.trackers << @tracker
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
it "should receive :prepare when the summarizer is preparing" do
|
15
15
|
@tracker.should_receive(:prepare).once
|
16
16
|
@summarizer.prepare
|
@@ -42,4 +42,10 @@ describe RequestLogAnalyzer::Tracker::Base, "API test" do
|
|
42
42
|
@summarizer.report(mock_output)
|
43
43
|
end
|
44
44
|
|
45
|
+
it "should receive :to_yaml object when finalizing" do
|
46
|
+
@summarizer.options[:dump] = temp_output_file(:dump)
|
47
|
+
@tracker.should_receive(:to_yaml_object).once
|
48
|
+
@summarizer.to_yaml
|
49
|
+
end
|
50
|
+
|
45
51
|
end
|
data/tasks/github-gem.rake
CHANGED
@@ -1,10 +1,26 @@
|
|
1
|
-
namespace :
|
2
|
-
desc "Analyze the Rails log file using the request-log-analyzer gem."
|
3
|
-
|
1
|
+
namespace :rla do
|
2
|
+
desc "Analyze the Rails log file using the request-log-analyzer gem."
|
3
|
+
task :report => :environment do
|
4
|
+
puts "Analyzing the Rails log file using the request-log-analyzer gem."
|
5
|
+
puts " Environment: #{RAILS_ENV}"
|
6
|
+
puts " Logfile: #{Rails.configuration.log_path}"
|
7
|
+
puts ""
|
8
|
+
IO.popen("request-log-analyzer #{Rails.configuration.log_path}") { |io| $stdout << io.read }
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
namespace :report do
|
13
|
+
desc "Analyze the Rails log file using the request-log-analyzer gem and output an HTML file."
|
14
|
+
task :html => :environment do
|
15
|
+
output_file = Rails.configuration.log_path + ".html"
|
16
|
+
|
4
17
|
puts "Analyzing the Rails log file using the request-log-analyzer gem."
|
5
|
-
puts "Environment: #{RAILS_ENV}"
|
6
|
-
puts "Logfile: #{Rails.configuration.log_path}"
|
18
|
+
puts " Environment: #{RAILS_ENV}"
|
19
|
+
puts " Logfile: #{Rails.configuration.log_path}"
|
20
|
+
puts " Output: #{output_file}"
|
7
21
|
puts ""
|
8
|
-
|
22
|
+
IO.popen("request-log-analyzer #{Rails.configuration.log_path} --output HTML --file #{output_file}") { |io| $stdout << io.read }
|
23
|
+
end
|
9
24
|
end
|
10
|
-
|
25
|
+
|
26
|
+
end
|
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.2.
|
4
|
+
version: 1.2.1
|
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-
|
13
|
+
date: 2009-07-15 00:00:00 +02:00
|
14
14
|
default_executable: request-log-analyzer
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -23,55 +23,49 @@ extensions: []
|
|
23
23
|
extra_rdoc_files:
|
24
24
|
- README.rdoc
|
25
25
|
files:
|
26
|
-
- DESIGN
|
27
|
-
- HACKING
|
26
|
+
- DESIGN.rdoc
|
28
27
|
- LICENSE
|
29
28
|
- README.rdoc
|
29
|
+
- RELEASE_NOTES.rdoc
|
30
30
|
- Rakefile
|
31
|
-
- bin
|
32
31
|
- bin/request-log-analyzer
|
33
|
-
- lib
|
34
|
-
- lib/cli
|
35
32
|
- lib/cli/command_line_arguments.rb
|
36
33
|
- lib/cli/progressbar.rb
|
37
34
|
- lib/cli/tools.rb
|
38
|
-
- lib/request_log_analyzer
|
39
35
|
- lib/request_log_analyzer.rb
|
40
|
-
- lib/request_log_analyzer/aggregator
|
41
36
|
- lib/request_log_analyzer/aggregator.rb
|
42
37
|
- lib/request_log_analyzer/aggregator/database.rb
|
43
38
|
- lib/request_log_analyzer/aggregator/echo.rb
|
44
39
|
- lib/request_log_analyzer/aggregator/summarizer.rb
|
45
40
|
- lib/request_log_analyzer/controller.rb
|
46
|
-
- lib/request_log_analyzer/file_format
|
47
41
|
- lib/request_log_analyzer/file_format.rb
|
48
42
|
- lib/request_log_analyzer/file_format/merb.rb
|
49
43
|
- lib/request_log_analyzer/file_format/rails.rb
|
50
44
|
- lib/request_log_analyzer/file_format/rails_development.rb
|
51
|
-
- lib/request_log_analyzer/filter
|
52
45
|
- lib/request_log_analyzer/filter.rb
|
53
46
|
- lib/request_log_analyzer/filter/anonymize.rb
|
54
47
|
- lib/request_log_analyzer/filter/field.rb
|
55
48
|
- lib/request_log_analyzer/filter/timespan.rb
|
56
49
|
- lib/request_log_analyzer/line_definition.rb
|
57
50
|
- lib/request_log_analyzer/log_processor.rb
|
58
|
-
- lib/request_log_analyzer/output
|
59
51
|
- lib/request_log_analyzer/output.rb
|
60
52
|
- lib/request_log_analyzer/output/fixed_width.rb
|
61
53
|
- lib/request_log_analyzer/output/html.rb
|
62
54
|
- lib/request_log_analyzer/request.rb
|
63
|
-
- lib/request_log_analyzer/source
|
64
55
|
- lib/request_log_analyzer/source.rb
|
65
56
|
- lib/request_log_analyzer/source/database.rb
|
66
57
|
- lib/request_log_analyzer/source/log_parser.rb
|
67
|
-
- lib/request_log_analyzer/tracker
|
68
58
|
- lib/request_log_analyzer/tracker.rb
|
69
59
|
- lib/request_log_analyzer/tracker/duration.rb
|
70
60
|
- lib/request_log_analyzer/tracker/frequency.rb
|
71
61
|
- lib/request_log_analyzer/tracker/hourly_spread.rb
|
72
62
|
- lib/request_log_analyzer/tracker/timespan.rb
|
73
|
-
- spec
|
74
|
-
- spec/fixtures
|
63
|
+
- spec/fixtures/decompression.log
|
64
|
+
- spec/fixtures/decompression.log.bz2
|
65
|
+
- spec/fixtures/decompression.log.gz
|
66
|
+
- spec/fixtures/decompression.log.zip
|
67
|
+
- spec/fixtures/decompression.tar.gz
|
68
|
+
- spec/fixtures/decompression.tgz
|
75
69
|
- spec/fixtures/merb.log
|
76
70
|
- spec/fixtures/multiple_files_1.log
|
77
71
|
- spec/fixtures/multiple_files_2.log
|
@@ -83,44 +77,36 @@ files:
|
|
83
77
|
- spec/fixtures/test_file_format.log
|
84
78
|
- spec/fixtures/test_language_combined.log
|
85
79
|
- spec/fixtures/test_order.log
|
86
|
-
- spec/integration
|
87
80
|
- spec/integration/command_line_usage_spec.rb
|
88
|
-
- spec/lib
|
89
81
|
- spec/lib/helper.rb
|
90
82
|
- spec/lib/mocks.rb
|
91
83
|
- spec/lib/testing_format.rb
|
92
84
|
- spec/spec_helper.rb
|
93
|
-
- spec/unit
|
94
|
-
- spec/unit/aggregator
|
95
85
|
- spec/unit/aggregator/database_inserter_spec.rb
|
96
86
|
- spec/unit/aggregator/summarizer_spec.rb
|
97
|
-
- spec/unit/controller
|
98
87
|
- spec/unit/controller/controller_spec.rb
|
99
88
|
- spec/unit/controller/log_processor_spec.rb
|
100
|
-
- spec/unit/file_format
|
101
89
|
- spec/unit/file_format/file_format_api_spec.rb
|
102
90
|
- spec/unit/file_format/line_definition_spec.rb
|
103
91
|
- spec/unit/file_format/merb_format_spec.rb
|
104
92
|
- spec/unit/file_format/rails_format_spec.rb
|
105
|
-
- spec/unit/filter
|
106
93
|
- spec/unit/filter/anonymize_filter_spec.rb
|
107
94
|
- spec/unit/filter/field_filter_spec.rb
|
108
95
|
- spec/unit/filter/timespan_filter_spec.rb
|
109
|
-
- spec/unit/source
|
110
96
|
- spec/unit/source/log_parser_spec.rb
|
111
97
|
- spec/unit/source/request_spec.rb
|
112
|
-
- spec/unit/tracker
|
113
98
|
- spec/unit/tracker/duration_tracker_spec.rb
|
114
99
|
- spec/unit/tracker/frequency_tracker_spec.rb
|
115
100
|
- spec/unit/tracker/hourly_spread_spec.rb
|
116
101
|
- spec/unit/tracker/timespan_tracker_spec.rb
|
117
|
-
- spec/unit/tracker/
|
118
|
-
- tasks
|
102
|
+
- spec/unit/tracker/tracker_api_spec.rb
|
119
103
|
- tasks/github-gem.rake
|
120
104
|
- tasks/request_log_analyzer.rake
|
121
105
|
- tasks/rspec.rake
|
122
106
|
has_rdoc: true
|
123
107
|
homepage: http://github.com/wvanbergen/request-log-analyzer/wikis
|
108
|
+
licenses: []
|
109
|
+
|
124
110
|
post_install_message:
|
125
111
|
rdoc_options:
|
126
112
|
- --title
|
@@ -146,9 +132,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
132
|
requirements: []
|
147
133
|
|
148
134
|
rubyforge_project: r-l-a
|
149
|
-
rubygems_version: 1.2
|
135
|
+
rubygems_version: 1.3.2
|
150
136
|
signing_key:
|
151
|
-
specification_version:
|
137
|
+
specification_version: 3
|
152
138
|
summary: A command line tool to analyze Rails logs
|
153
139
|
test_files:
|
154
140
|
- spec/integration/command_line_usage_spec.rb
|
@@ -169,3 +155,4 @@ test_files:
|
|
169
155
|
- spec/unit/tracker/frequency_tracker_spec.rb
|
170
156
|
- spec/unit/tracker/hourly_spread_spec.rb
|
171
157
|
- spec/unit/tracker/timespan_tracker_spec.rb
|
158
|
+
- spec/unit/tracker/tracker_api_spec.rb
|
data/HACKING
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
HACKING on request-log-analyzer
|
2
|
-
-------------------------------
|
3
|
-
|
4
|
-
- See DESIGN for the basic internal design of request-log-analyzer
|
5
|
-
- See http://wiki.github.com/wvanbergen/request-log-analyzer/development for
|
6
|
-
more information about developing
|
7
|
-
- Contact me at my GitHub account for any questions: http://github.com/wvanbergen
|