class RequestLogAnalyzer::FileFormat::Base

Base class for all log file format definitions. This class provides functions for subclasses to define their LineDefinitions and to define a summary report.

A subclass of this class is instantiated when request-log-analyzer is started and this instance is shared with all components of the application so they can act on the specifics of the format

Constants

Request

Setup the default Request class.

Attributes

line_definitions[R]
report_trackers[R]

Public Class Methods

create(*_args) click to toggle source

Instantiation

    # File lib/request_log_analyzer/file_format.rb
245 def self.create(*_args)
246   # Ignore arguments
247   new(line_definer.line_definitions, report_definer.trackers)
248 end
format_definition() { |line_definer| ... } click to toggle source

Specifies multiple line definitions at once using a block

    # File lib/request_log_analyzer/file_format.rb
214 def self.format_definition(&_block)
215   if block_given?
216     yield line_definer
217   else
218     return line_definer
219   end
220 end
line_definer() click to toggle source

Setup the default line definer.

    # File lib/request_log_analyzer/file_format.rb
229 def self.line_definer
230   @line_definer ||= ::RequestLogAnalyzer::LineDefinition::Definer.new
231 end
line_definition(name, &block) click to toggle source

Specifies a single line defintions.

    # File lib/request_log_analyzer/file_format.rb
209 def self.line_definition(name, &block)
210   line_definer.define_line(name, &block)
211 end
new(line_definitions = {}, report_trackers = []) click to toggle source
    # File lib/request_log_analyzer/file_format.rb
250 def initialize(line_definitions = {}, report_trackers = [])
251   @line_definitions, @report_trackers = line_definitions, report_trackers
252 end
report(mode = :append) { |report_definer| ... } click to toggle source

Specifies the summary report using a block.

    # File lib/request_log_analyzer/file_format.rb
223 def self.report(mode = :append, &_block)
224   report_definer.reset! if mode == :overwrite
225   yield(report_definer)
226 end
report_definer() click to toggle source

Setup the default report definer.

    # File lib/request_log_analyzer/file_format.rb
234 def self.report_definer
235   @report_definer ||= ::RequestLogAnalyzer::Aggregator::Summarizer::Definer.new
236 end

Public Instance Methods

captures?(name) click to toggle source

Returns true if this language captures the given symbol in one of its line definitions

    # File lib/request_log_analyzer/file_format.rb
287 def captures?(name)
288   line_definitions.any? { |(_, ld)| ld.captures?(name) }
289 end
line_divider() click to toggle source
    # File lib/request_log_analyzer/file_format.rb
311 def line_divider
312   self.class.const_get(LINE_DIVIDER) if self.class.const_defined?(:LINE_DIVIDER)
313 end
max_line_length() click to toggle source

Returns the max line length for this file format if any.

    # File lib/request_log_analyzer/file_format.rb
307 def max_line_length
308   self.class.const_get(MAX_LINE_LENGTH) if self.class.const_defined?(:MAX_LINE_LENGTH)
309 end
parse_line(line, &warning_handler) click to toggle source

Parses a line by trying to parse it using every line definition in this file format

    # File lib/request_log_analyzer/file_format.rb
297 def parse_line(line, &warning_handler)
298   line_definitions.each do |_lt, definition|
299     match = definition.matches(line, &warning_handler)
300     return match if match
301   end
302 
303   nil
304 end
request(*hashes) click to toggle source

Returns a Request instance with the given parsed lines that should be provided as hashes.

    # File lib/request_log_analyzer/file_format.rb
264 def request(*hashes)
265   request_class.create(self, *hashes)
266 end
request_class() click to toggle source

Returns the Request class of this file format

    # File lib/request_log_analyzer/file_format.rb
259 def request_class
260   self.class::Request
261 end
setup_environment(_controller) click to toggle source

Function that a file format con implement to monkey patch the environment.

  • controller The environment is provided as a controller instance

    # File lib/request_log_analyzer/file_format.rb
293 def setup_environment(_controller)
294 end
valid?()
Alias for: well_formed?
valid_line_definitions?() click to toggle source

Checks whether the line definitions form a valid language. A file format should have at least a header and a footer line type

    # File lib/request_log_analyzer/file_format.rb
277 def valid_line_definitions?
278   line_definitions.any? { |(_, ld)| ld.header } && line_definitions.any? { |(_, ld)| ld.footer }
279 end
valid_request_class?() click to toggle source

Checks whether the request class inherits from the base Request class.

    # File lib/request_log_analyzer/file_format.rb
282 def valid_request_class?
283   request_class.ancestors.include?(RequestLogAnalyzer::Request)
284 end
well_formed?() click to toggle source

Checks whether the file format is valid so it can be safely used with RLA.

    # File lib/request_log_analyzer/file_format.rb
269 def well_formed?
270   valid_line_definitions? && valid_request_class?
271 end
Also aliased as: valid?