request-log-analyzer 1.3.2 → 1.3.3

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.
@@ -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.2"
14
+ VERSION = "1.3.3"
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.
@@ -0,0 +1,61 @@
1
+ module RequestLogAnalyzer::FileFormat
2
+
3
+ # FileFormat for Amazon S3 access logs.
4
+ #
5
+ # Access logs are disabled by default on Amazon S3. To enable logging, see
6
+ # http://docs.amazonwebservices.com/AmazonS3/latest/index.html?ServerLogs.html
7
+ class AmazonS3 < Base
8
+
9
+ line_definition :access do |line|
10
+ line.header = true
11
+ line.footer = true
12
+ line.regexp = /^([^\ ]+) ([^\ ]+) \[([^\]]{26})\] (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) ([^\ ]+) ([^\ ]+) (\w+(?:\.\w+)*) ([^\ ]+) "([^"]+)" (\d+) ([^\ ]+) (\d+) (\d+) (\d+) (\d+) "([^"]+)" "([^"]+)"/
13
+ line.captures << { :name => :bucket_owner, :type => :string } <<
14
+ { :name => :bucket, :type => :string } <<
15
+ { :name => :timestamp, :type => :timestamp } <<
16
+ { :name => :remote_ip, :type => :string } <<
17
+ { :name => :requester, :type => :string } <<
18
+ { :name => :request_id, :type => :string } <<
19
+ { :name => :operation, :type => :string } <<
20
+ { :name => :key, :type => :nillable_string } <<
21
+ { :name => :request_uri, :type => :string } <<
22
+ { :name => :http_status, :type => :integer } <<
23
+ { :name => :error_code, :type => :nillable_string } <<
24
+ { :name => :bytes_sent, :type => :integer } <<
25
+ { :name => :object_size, :type => :integer } <<
26
+ { :name => :total_time, :type => :duration, :unit => :msec } <<
27
+ { :name => :turnaround_time, :type => :duration, :unit => :msec } <<
28
+ { :name => :referer, :type => :referer } <<
29
+ { :name => :user_agent, :type => :user_agent }
30
+ end
31
+
32
+ class Request < RequestLogAnalyzer::Request
33
+
34
+ MONTHS = {'Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06',
35
+ 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12' }
36
+
37
+ # Do not use DateTime.parse, but parse the timestamp ourselves to return a integer
38
+ # to speed up parsing.
39
+ def convert_timestamp(value, definition)
40
+ d = /^(\d{2})\/(\w{3})\/(\d{4}):(\d{2}):(\d{2}):(\d{2})/.match(value).captures
41
+ "#{d[2]}#{MONTHS[d[1]]}#{d[0]}#{d[3]}#{d[4]}#{d[5]}".to_i
42
+ end
43
+
44
+ # Make sure that the string '-' is parsed as a nil value.
45
+ def convert_nillable_string(value, definition)
46
+ value == '-' ? nil : value
47
+ end
48
+
49
+ # Can be implemented in subclasses for improved categorizations
50
+ def convert_referer(value, definition)
51
+ value == '-' ? nil : value
52
+ end
53
+
54
+ # Can be implemented in subclasses for improved categorizations
55
+ def convert_user_agent(value, definition)
56
+ value == '-' ? nil : value
57
+ end
58
+ end
59
+
60
+ end
61
+ end
@@ -1,14 +1,20 @@
1
- # 125.76.230.10 - - [02/Sep/2009:03:33:46 +0200] "GET /cart/install.txt HTTP/1.1" 404 214 "-" "Toata dragostea mea pentru diavola"
2
- # 125.76.230.10 - - [02/Sep/2009:03:33:47 +0200] "GET /store/install.txt HTTP/1.1" 404 215 "-" "Toata dragostea mea pentru diavola"
3
- # 10.0.1.1 - - [02/Sep/2009:05:08:33 +0200] "GET / HTTP/1.1" 200 30 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9"
4
- # 10.0.1.1 - - [02/Sep/2009:06:41:51 +0200] "GET / HTTP/1.1" 200 30 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9"
5
- # 69.41.0.45 - - [02/Sep/2009:12:02:40 +0200] "GET //phpMyAdmin/ HTTP/1.1" 404 209 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)"
6
-
7
1
  module RequestLogAnalyzer::FileFormat
8
2
 
3
+ # The Apache file format is able to log Apache access.log files.
4
+ #
5
+ # The access.log can be configured in Apache to have many different formats. In theory, this
6
+ # FileFormat can handle any format, but it must be aware of the log formatting that is used
7
+ # by sending the formatting string as parameter to the create method, e.g.:
8
+ #
9
+ # RequestLogAnalyzer::FileFormat::Apache.create('%h %l %u %t "%r" %>s %b')
10
+ #
11
+ # It also supports the predefined Apache log formats "common" and "combined". The line
12
+ # definition and the report definition will be constructed using this file format string.
13
+ # From the command line, you can provide the format string using the <tt>--apache-format</tt>
14
+ # command line option.
9
15
  class Apache < Base
10
16
 
11
- # A hash of predefined Apache log format strings
17
+ # A hash of predefined Apache log formats
12
18
  LOG_FORMAT_DEFAULTS = {
13
19
  :common => '%h %l %u %t "%r" %>s %b',
14
20
  :combined => '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"'
@@ -16,17 +22,19 @@ module RequestLogAnalyzer::FileFormat
16
22
 
17
23
  # A hash that defines how the log format directives should be parsed.
18
24
  LOG_DIRECTIVES = {
25
+ '%' => { :regexp => '%', :captures => [] },
19
26
  'h' => { :regexp => '([A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+)', :captures => [{:name => :remote_host, :type => :string}] },
20
27
  'a' => { :regexp => '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', :captures => [{:name => :remote_ip, :type => :string}] },
21
28
  'b' => { :regexp => '(\d+|-)', :captures => [{:name => :bytes_sent, :type => :integer}] },
22
29
  'c' => { :regexp => '(\+|\-|\X)', :captures => [{:name => :connection_status, :type => :integer}] },
30
+ 'D' => { :regexp => '(\d+|-)', :captures => [{:name => :duration, :type => :duration, :unit => :msec}] },
23
31
  'l' => { :regexp => '([\w-]+)', :captures => [{:name => :remote_logname, :type => :nillable_string}] },
24
- 'T' => { :regexp => '((?:\d+(?:\.\d+)?)|-)', :captures => [{:name => :duration, :type => :duration, :unit => :sec}] },
32
+ 'T' => { :regexp => '(\d+|-)', :captures => [{:name => :duration, :type => :duration, :unit => :sec}] },
25
33
  't' => { :regexp => '\[([^\]]{26})\]', :captures => [{:name => :timestamp, :type => :timestamp}] },
26
34
  's' => { :regexp => '(\d{3})', :captures => [{:name => :http_status, :type => :integer}] },
27
35
  'u' => { :regexp => '(\w+|-)', :captures => [{:name => :user, :type => :nillable_string}] },
28
36
  'r' => { :regexp => '([A-Z]+) ([^\s]+) HTTP\/(\d+(?:\.\d+)*)', :captures => [{:name => :http_method, :type => :string},
29
- {:name => :path, :type => :string}, {:name => :http_version, :type => :string}]},
37
+ {:name => :path, :type => :path}, {:name => :http_version, :type => :string}]},
30
38
  'i' => { 'Referer' => { :regexp => '([^\s]+)', :captures => [{:name => :referer, :type => :nillable_string}] },
31
39
  'User-agent' => { :regexp => '(.*)', :captures => [{:name => :user_agent, :type => :user_agent}] }
32
40
  }
@@ -47,7 +55,7 @@ module RequestLogAnalyzer::FileFormat
47
55
 
48
56
  line_regexp = ''
49
57
  captures = []
50
- format_string.scan(/([^%]*)(?:%(?:\{([^\}]+)\})?>?([A-Za-z]))?/) do |literal, arg, variable|
58
+ format_string.scan(/([^%]*)(?:%(?:\{([^\}]+)\})?>?([A-Za-z%]))?/) do |literal, arg, variable|
51
59
 
52
60
  line_regexp << Regexp.quote(literal) # Make sure to parse the literal before the directive
53
61
 
@@ -60,6 +68,7 @@ module RequestLogAnalyzer::FileFormat
60
68
  line_regexp << directive[:regexp] # Parse the value of the directive
61
69
  captures += directive[:captures] # Add the directive's information to the captures
62
70
  else
71
+ puts "%#{directive} log directiven not yet supported, field is ignored."
63
72
  line_regexp << '.*' # Just accept any input for this literal
64
73
  end
65
74
  end
@@ -70,7 +79,7 @@ module RequestLogAnalyzer::FileFormat
70
79
  :captures => captures, :header => true, :footer => true)
71
80
  end
72
81
 
73
- # Sets up the report trackers according to the access line definition.
82
+ # Sets up the report trackers according to the fields captured by the access line definition.
74
83
  def self.report_trackers(line_definition)
75
84
  analyze = RequestLogAnalyzer::Aggregator::Summarizer::Definer.new
76
85
 
@@ -97,16 +106,26 @@ module RequestLogAnalyzer::FileFormat
97
106
  MONTHS = {'Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06',
98
107
  'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12' }
99
108
 
100
- # Do not use DateTime.parse
109
+ # Do not use DateTime.parse, but parse the timestamp ourselves to return a integer
110
+ # to speed up parsing.
101
111
  def convert_timestamp(value, definition)
102
112
  d = /^(\d{2})\/(\w{3})\/(\d{4}):(\d{2}):(\d{2}):(\d{2})/.match(value).captures
103
113
  "#{d[2]}#{MONTHS[d[1]]}#{d[0]}#{d[3]}#{d[4]}#{d[5]}".to_i
104
114
  end
105
115
 
116
+ # This function can be overridden to rewrite the path for better categorization in the
117
+ # reports.
118
+ def convert_path(value, definition)
119
+ value
120
+ end
121
+
122
+ # This function can be overridden to simplify the user agent string for better
123
+ # categorization in the reports
106
124
  def convert_user_agent(value, definition)
107
125
  value # TODO
108
126
  end
109
127
 
128
+ # Make sure that the string '-' is parsed as a nil value.
110
129
  def convert_nillable_string(value, definition)
111
130
  value == '-' ? nil : value
112
131
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "request-log-analyzer"
3
- s.version = "1.3.2"
4
- s.date = "2009-09-13"
3
+ s.version = "1.3.3"
4
+ s.date = "2009-09-14"
5
5
 
6
6
  s.rubyforge_project = 'r-l-a'
7
7
 
@@ -31,6 +31,6 @@ Gem::Specification.new do |s|
31
31
  s.email = ['willem@railsdoctors.com', 'bart@railsdoctors.com']
32
32
  s.homepage = 'http://railsdoctors.com'
33
33
 
34
- s.files = %w(spec/unit/filter/anonymize_filter_spec.rb lib/request_log_analyzer/line_definition.rb lib/request_log_analyzer/output/html.rb lib/request_log_analyzer/controller.rb spec/fixtures/rails_22_cached.log spec/lib/macros.rb lib/request_log_analyzer/file_format/rails_development.rb spec/fixtures/apache_combined.log spec/fixtures/apache_common.log spec/fixtures/merb_prefixed.log tasks/request_log_analyzer.rake spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/command_line_usage_spec.rb lib/request_log_analyzer/database.rb spec/fixtures/decompression.log.bz2 lib/request_log_analyzer/log_processor.rb lib/request_log_analyzer/tracker.rb lib/request_log_analyzer/filter.rb spec/fixtures/rails_unordered.log bin/request-log-analyzer request-log-analyzer.gemspec DESIGN.rdoc spec/unit/filter/timespan_filter_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/lib/matchers.rb lib/request_log_analyzer/filter/field.rb lib/request_log_analyzer/tracker/frequency.rb spec/fixtures/decompression.log.gz spec/fixtures/decompression.log spec/lib/testing_format.rb spec/fixtures/test_order.log spec/fixtures/rails.db lib/request_log_analyzer/output/fixed_width.rb lib/request_log_analyzer/filter/anonymize.rb lib/request_log_analyzer/tracker/timespan.rb lib/request_log_analyzer/database/base.rb lib/request_log_analyzer/aggregator.rb lib/cli/progressbar.rb lib/request_log_analyzer/mailer.rb README.rdoc spec/fixtures/merb.log lib/request_log_analyzer/tracker/hourly_spread.rb .gitignore spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/duration_tracker_spec.rb lib/request_log_analyzer/aggregator/echo.rb spec/unit/controller/log_processor_spec.rb spec/spec_helper.rb lib/request_log_analyzer.rb spec/database.yml Rakefile lib/request_log_analyzer/database/connection.rb spec/unit/filter/filter_spec.rb spec/fixtures/test_language_combined.log lib/request_log_analyzer/aggregator/database_inserter.rb lib/request_log_analyzer/aggregator/summarizer.rb lib/request_log_analyzer/file_format/rails.rb spec/fixtures/decompression.tar.gz spec/unit/filter/field_filter_spec.rb spec/unit/database/base_class_spec.rb lib/request_log_analyzer/filter/timespan.rb lib/request_log_analyzer/source/log_parser.rb spec/fixtures/decompression.tgz spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/fixtures/header_and_footer.log lib/cli/tools.rb lib/request_log_analyzer/file_format/merb.rb spec/fixtures/multiple_files_1.log spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/line_definition_spec.rb lib/request_log_analyzer/source.rb lib/request_log_analyzer/request.rb lib/cli/database_console.rb spec/unit/database/connection_spec.rb spec/unit/controller/controller_spec.rb spec/lib/mocks.rb spec/lib/helpers.rb lib/cli/database_console_init.rb lib/request_log_analyzer/output.rb lib/request_log_analyzer/file_format/apache.rb spec/fixtures/rails_1x.log spec/fixtures/decompression.log.zip spec/unit/source/request_spec.rb spec/unit/source/log_parser_spec.rb spec/fixtures/test_file_format.log tasks/github-gem.rake spec/unit/database/database_spec.rb lib/request_log_analyzer/tracker/duration.rb lib/request_log_analyzer/file_format.rb spec/unit/aggregator/summarizer_spec.rb spec/fixtures/rails_22.log spec/fixtures/multiple_files_2.log spec/fixtures/syslog_1x.log LICENSE lib/request_log_analyzer/source/database_loader.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/rails_format_spec.rb lib/cli/command_line_arguments.rb)
35
- s.test_files = %w(spec/unit/filter/anonymize_filter_spec.rb spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/command_line_usage_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/controller/log_processor_spec.rb spec/unit/filter/filter_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/database/base_class_spec.rb spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/line_definition_spec.rb spec/unit/database/connection_spec.rb spec/unit/controller/controller_spec.rb spec/unit/source/request_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/database/database_spec.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/rails_format_spec.rb)
34
+ s.files = %w(spec/unit/filter/anonymize_filter_spec.rb lib/request_log_analyzer/line_definition.rb lib/request_log_analyzer/output/html.rb lib/request_log_analyzer/controller.rb spec/fixtures/rails_22_cached.log spec/lib/macros.rb lib/request_log_analyzer/file_format/rails_development.rb spec/fixtures/apache_combined.log spec/fixtures/apache_common.log spec/fixtures/merb_prefixed.log lib/request_log_analyzer/file_format/amazon_s3.rb tasks/request_log_analyzer.rake spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/command_line_usage_spec.rb lib/request_log_analyzer/database.rb spec/fixtures/decompression.log.bz2 lib/request_log_analyzer/log_processor.rb lib/request_log_analyzer/tracker.rb lib/request_log_analyzer/filter.rb spec/fixtures/rails_unordered.log bin/request-log-analyzer request-log-analyzer.gemspec DESIGN.rdoc spec/unit/filter/timespan_filter_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/lib/matchers.rb lib/request_log_analyzer/filter/field.rb lib/request_log_analyzer/tracker/frequency.rb spec/fixtures/decompression.log.gz spec/fixtures/decompression.log spec/lib/testing_format.rb spec/fixtures/test_order.log spec/fixtures/rails.db lib/request_log_analyzer/output/fixed_width.rb lib/request_log_analyzer/filter/anonymize.rb lib/request_log_analyzer/tracker/timespan.rb lib/request_log_analyzer/database/base.rb lib/request_log_analyzer/aggregator.rb lib/cli/progressbar.rb lib/request_log_analyzer/mailer.rb README.rdoc spec/fixtures/merb.log lib/request_log_analyzer/tracker/hourly_spread.rb .gitignore spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb lib/request_log_analyzer/aggregator/echo.rb spec/unit/controller/log_processor_spec.rb spec/spec_helper.rb lib/request_log_analyzer.rb spec/database.yml Rakefile lib/request_log_analyzer/database/connection.rb spec/unit/filter/filter_spec.rb spec/fixtures/test_language_combined.log lib/request_log_analyzer/aggregator/database_inserter.rb lib/request_log_analyzer/aggregator/summarizer.rb lib/request_log_analyzer/file_format/rails.rb spec/fixtures/decompression.tar.gz spec/unit/filter/field_filter_spec.rb spec/unit/database/base_class_spec.rb lib/request_log_analyzer/filter/timespan.rb lib/request_log_analyzer/source/log_parser.rb spec/fixtures/decompression.tgz spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/fixtures/header_and_footer.log lib/cli/tools.rb lib/request_log_analyzer/file_format/merb.rb spec/fixtures/multiple_files_1.log spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/line_definition_spec.rb lib/request_log_analyzer/source.rb lib/request_log_analyzer/request.rb lib/cli/database_console.rb spec/unit/database/connection_spec.rb spec/unit/controller/controller_spec.rb spec/lib/mocks.rb spec/lib/helpers.rb lib/cli/database_console_init.rb lib/request_log_analyzer/output.rb lib/request_log_analyzer/file_format/apache.rb spec/fixtures/rails_1x.log spec/fixtures/decompression.log.zip spec/unit/source/request_spec.rb spec/unit/source/log_parser_spec.rb spec/fixtures/test_file_format.log tasks/github-gem.rake spec/unit/database/database_spec.rb lib/request_log_analyzer/tracker/duration.rb lib/request_log_analyzer/file_format.rb spec/unit/aggregator/summarizer_spec.rb spec/fixtures/rails_22.log spec/fixtures/multiple_files_2.log spec/fixtures/syslog_1x.log LICENSE lib/request_log_analyzer/source/database_loader.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/rails_format_spec.rb lib/cli/command_line_arguments.rb)
35
+ s.test_files = %w(spec/unit/filter/anonymize_filter_spec.rb spec/unit/file_format/file_format_api_spec.rb spec/unit/file_format/apache_format_spec.rb spec/integration/command_line_usage_spec.rb spec/unit/filter/timespan_filter_spec.rb spec/unit/aggregator/database_inserter_spec.rb spec/unit/tracker/tracker_api_spec.rb spec/unit/tracker/duration_tracker_spec.rb spec/unit/file_format/amazon_s3_format_spec.rb spec/unit/controller/log_processor_spec.rb spec/unit/filter/filter_spec.rb spec/unit/filter/field_filter_spec.rb spec/unit/database/base_class_spec.rb spec/unit/tracker/timespan_tracker_spec.rb spec/unit/tracker/hourly_spread_spec.rb spec/unit/file_format/merb_format_spec.rb spec/unit/file_format/line_definition_spec.rb spec/unit/database/connection_spec.rb spec/unit/controller/controller_spec.rb spec/unit/source/request_spec.rb spec/unit/source/log_parser_spec.rb spec/unit/database/database_spec.rb spec/unit/aggregator/summarizer_spec.rb spec/unit/tracker/frequency_tracker_spec.rb spec/unit/file_format/rails_format_spec.rb)
36
36
  end
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe RequestLogAnalyzer::FileFormat::AmazonS3 do
4
+
5
+ before(:each) do
6
+ @file_format = RequestLogAnalyzer::FileFormat.load(:amazon_s3)
7
+ @log_parser = RequestLogAnalyzer::Source::LogParser.new(@file_format)
8
+ @sample = '2f88111968424e6306bf4d292c0188ccb94ff9374ea2836b50a1a79f7cd656e1 sample-bucket [06/Oct/2006:01:42:14 +0000] 207.171.172.6 65a011a29cdf8ec533ec3d1ccaae921c C980091AD89C936A REST.GET.OBJECT object.png "GET /sample-bucket/object.png HTTP/1.1" 200 - 1243 1243 988 987 "-" "aranhabot"'
9
+ end
10
+
11
+ it "should be a valid file format" do
12
+ @file_format.should be_valid
13
+ end
14
+
15
+ it "should parse access lines and capture all of its fields" do
16
+ @file_format.should have_line_definition(:access).capturing(:bucket_owner, :bucket, :timestamp, :remote_ip, :requester,
17
+ :key, :operation, :total_time, :turnaround_time, :bytes_sent, :object_size, :referer, :user_agent)
18
+ end
19
+
20
+ it "should match the sample line" do
21
+ @file_format.parse_line(@sample).should include(:line_definition, :captures)
22
+ end
23
+
24
+ it "should not match a nonsense line" do
25
+ @file_format.parse_line('dsadasdas dsaadsads dsaadsads').should be_nil
26
+ end
27
+
28
+ it "should parse and convert the sample fields correctly" do
29
+ @log_parser.parse_io(StringIO.new(@sample)) do |request|
30
+ request[:bucket_owner].should == '2f88111968424e6306bf4d292c0188ccb94ff9374ea2836b50a1a79f7cd656e1'
31
+ request[:bucket].should == 'sample-bucket'
32
+ request[:remote_ip].should == '207.171.172.6'
33
+ request[:key].should == 'object.png'
34
+ request[:operation].should == 'REST.GET.OBJECT'
35
+ request[:requester].should == '65a011a29cdf8ec533ec3d1ccaae921c'
36
+ request[:request_id].should == 'C980091AD89C936A'
37
+ request[:request_uri].should == 'GET /sample-bucket/object.png HTTP/1.1'
38
+ request[:error_code].should == nil
39
+ request[:http_status].should == 200
40
+ request[:total_time].should == 0.988
41
+ request[:turnaround_time].should == 0.987
42
+ request[:bytes_sent].should == 1243
43
+ request[:object_size].should == 1243
44
+ request[:user_agent].should == 'aranhabot'
45
+ request[:referer].should == nil
46
+ end
47
+ end
48
+
49
+ 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.3.2
4
+ version: 1.3.3
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 00:00:00 +02:00
13
+ date: 2009-09-14 00:00:00 +02:00
14
14
  default_executable: request-log-analyzer
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -54,6 +54,7 @@ files:
54
54
  - spec/fixtures/apache_combined.log
55
55
  - spec/fixtures/apache_common.log
56
56
  - spec/fixtures/merb_prefixed.log
57
+ - lib/request_log_analyzer/file_format/amazon_s3.rb
57
58
  - tasks/request_log_analyzer.rake
58
59
  - spec/unit/file_format/file_format_api_spec.rb
59
60
  - spec/unit/file_format/apache_format_spec.rb
@@ -90,6 +91,7 @@ files:
90
91
  - .gitignore
91
92
  - spec/unit/tracker/tracker_api_spec.rb
92
93
  - spec/unit/tracker/duration_tracker_spec.rb
94
+ - spec/unit/file_format/amazon_s3_format_spec.rb
93
95
  - lib/request_log_analyzer/aggregator/echo.rb
94
96
  - spec/unit/controller/log_processor_spec.rb
95
97
  - spec/spec_helper.rb
@@ -186,6 +188,7 @@ test_files:
186
188
  - spec/unit/aggregator/database_inserter_spec.rb
187
189
  - spec/unit/tracker/tracker_api_spec.rb
188
190
  - spec/unit/tracker/duration_tracker_spec.rb
191
+ - spec/unit/file_format/amazon_s3_format_spec.rb
189
192
  - spec/unit/controller/log_processor_spec.rb
190
193
  - spec/unit/filter/filter_spec.rb
191
194
  - spec/unit/filter/field_filter_spec.rb