Class: RequestLogAnalyzer::FileFormat::Apache::Request
- Defined in:
- lib/request_log_analyzer/file_format/apache.rb
Overview
Define a custom Request class for the Apache file format to speed up timestamp handling.
Constant Summary collapse
- MONTHS =
{'Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12' }
Instance Attribute Summary
Attributes inherited from Request
#attributes, #file_format, #lines
Instance Method Summary collapse
- #category ⇒ Object
-
#convert_nillable_string(value, definition) ⇒ Object
Make sure that the string ‘-’ is parsed as a nil value.
-
#convert_path(value, definition) ⇒ Object
This function can be overridden to rewrite the path for better categorization in the reports.
-
#convert_timestamp(value, definition) ⇒ Object
Do not use DateTime.parse, but parse the timestamp ourselves to return a integer to speed up parsing.
-
#convert_user_agent(value, definition) ⇒ Object
This function can be overridden to simplify the user agent string for better categorization in the reports.
Methods inherited from Request
#<<, #add_line_hash, #add_parsed_line, #completed?, create, #empty?, #every, #first, #first_lineno, #has_line_type?, #initialize, #last_lineno, #timestamp, #validate
Methods included from Request::Converters
#convert_decimal, #convert_duration, #convert_eval, #convert_float, #convert_int, #convert_integer, #convert_string, #convert_sym, #convert_symbol, #convert_traffic, #convert_value
Constructor Details
This class inherits a constructor from RequestLogAnalyzer::Request
Instance Method Details
#category ⇒ Object
109 110 111 |
# File 'lib/request_log_analyzer/file_format/apache.rb', line 109 def category first(:path) end |
#convert_nillable_string(value, definition) ⇒ Object
Make sure that the string ‘-’ is parsed as a nil value.
135 136 137 |
# File 'lib/request_log_analyzer/file_format/apache.rb', line 135 def convert_nillable_string(value, definition) value == '-' ? nil : value end |
#convert_path(value, definition) ⇒ Object
This function can be overridden to rewrite the path for better categorization in the reports.
124 125 126 |
# File 'lib/request_log_analyzer/file_format/apache.rb', line 124 def convert_path(value, definition) value end |
#convert_timestamp(value, definition) ⇒ Object
Do not use DateTime.parse, but parse the timestamp ourselves to return a integer to speed up parsing.
118 119 120 |
# File 'lib/request_log_analyzer/file_format/apache.rb', line 118 def (value, definition) "#{value[7,4]}#{MONTHS[value[3,3]]}#{value[0,2]}#{value[12,2]}#{value[15,2]}#{value[18,2]}".to_i end |
#convert_user_agent(value, definition) ⇒ Object
This function can be overridden to simplify the user agent string for better categorization in the reports
130 131 132 |
# File 'lib/request_log_analyzer/file_format/apache.rb', line 130 def convert_user_agent(value, definition) value # TODO end |