Class: ApacheCrunch::LogParserFactory
- Inherits:
-
Object
- Object
- ApacheCrunch::LogParserFactory
- Defined in:
- lib/log_parser.rb
Overview
Makes a LogParser given the parameters we want to work with.
This is the class that most external code should instatiate to begin using this library.
Class Method Summary collapse
-
.log_parser(format_def, path, progress_meter) ⇒ Object
Returns a new LogParser instance for the given log file, which should have the given Apache log format.
Class Method Details
.log_parser(format_def, path, progress_meter) ⇒ Object
Returns a new LogParser instance for the given log file, which should have the given Apache log format.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/log_parser.rb', line 67 def self.log_parser(format_def, path, progress_meter) # First we generate a Format instance based on the format definition we were given log_format = FormatFactory.from_format_def(format_def) # Now we generate a parser for the individual entries entry_parser = EntryParser.new entry_parser.add_progress_meter!(progress_meter) # And now we can instantiate and return a LogParser log_parser = LogParser.new(entry_parser) log_parser.set_file!(open(path, "r")) log_parser.set_format!(log_format) log_parser end |