Class: Kafo::PuppetLogParser
- Inherits:
-
Object
- Object
- Kafo::PuppetLogParser
- Defined in:
- lib/kafo/puppet_log_parser.rb
Instance Method Summary collapse
-
#initialize ⇒ PuppetLogParser
constructor
A new instance of PuppetLogParser.
- #parse(line) ⇒ Object
Constructor Details
#initialize ⇒ PuppetLogParser
Returns a new instance of PuppetLogParser.
3 4 5 |
# File 'lib/kafo/puppet_log_parser.rb', line 3 def initialize @last_level = nil end |
Instance Method Details
#parse(line) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/kafo/puppet_log_parser.rb', line 7 def parse(line) method, = case when line =~ /^Error:(.*)/i || line =~ /^Err:(.*)/i [:error, $1] when line =~ /^Notice:(.*)/i [:info, $1] when line =~ /^Warning:(.*)/i || line =~ /^Debug:(.*)/i || line =~ /^Info:(.*)/i [:debug, $1] else [@last_level.nil? ? :info : @last_level, line] end if .include?('Loading facts') && method != :error method = :debug end if .include?('Applying configuration version') method = :debug end @last_level = method return [method, .chomp.strip] end |