Class: Dexter::LogParser
- Inherits:
-
Object
- Object
- Dexter::LogParser
- Defined in:
- lib/dexter/log_parser.rb
Constant Summary collapse
- REGEX =
/duration: (\d+\.\d+) ms (statement|execute <unnamed>): (.+)/- LINE_SEPERATOR =
": ".freeze
Instance Method Summary collapse
-
#initialize(logfile, collector) ⇒ LogParser
constructor
A new instance of LogParser.
- #perform ⇒ Object
Constructor Details
#initialize(logfile, collector) ⇒ LogParser
Returns a new instance of LogParser.
6 7 8 9 |
# File 'lib/dexter/log_parser.rb', line 6 def initialize(logfile, collector) @logfile = logfile @collector = collector end |
Instance Method Details
#perform ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dexter/log_parser.rb', line 11 def perform active_line = nil duration = nil each_line do |line| if active_line if line.include?(LINE_SEPERATOR) process_entry(active_line, duration) active_line = nil else active_line << line end end if !active_line && m = REGEX.match(line.chomp) duration = m[1].to_f active_line = m[3] end end process_entry(active_line, duration) if active_line end |