class Kafo::PuppetLogParser

Public Class Methods

new() click to toggle source
# File lib/kafo/puppet_log_parser.rb, line 3
def initialize
  @last_level = nil
end

Public Instance Methods

parse(line) click to toggle source
# File lib/kafo/puppet_log_parser.rb, line 7
def parse(line)
  method, message = 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 message.include?('Loading facts') && method != :error
    method = :debug
  end

  if message.include?('Applying configuration version')
    method = :debug
  end

  @last_level = method
  return [method, message.chomp.strip]
end