Class: Dexter::StderrLogParser

Inherits:
LogParser show all
Defined in:
lib/dexter/stderr_log_parser.rb

Constant Summary collapse

LINE_SEPERATOR =
":  ".freeze
DETAIL_LINE =
"DETAIL:  ".freeze

Constants inherited from LogParser

LogParser::REGEX

Constants included from Logging

Logging::COLOR_CODES

Instance Method Summary collapse

Methods inherited from LogParser

#initialize

Methods included from Logging

#colorize, #log, #output

Constructor Details

This class inherits a constructor from Dexter::LogParser

Instance Method Details

#performObject



6
7
8
# File 'lib/dexter/stderr_log_parser.rb', line 6

def perform
  process_stderr(@logfile.each_line)
end

#process_stderr(rows) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dexter/stderr_log_parser.rb', line 10

def process_stderr(rows)
  active_line = nil
  duration = nil

  rows.each do |line|
    if active_line
      if line.include?(DETAIL_LINE)
        add_parameters(active_line, line.chomp.split(DETAIL_LINE)[1])
      elsif 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