Class: Bolt::R10KLogProxy

Inherits:
Log4r::Outputter
  • Object
show all
Defined in:
lib/bolt/r10k_log_proxy.rb

Instance Method Summary collapse

Constructor Details

#initializeR10KLogProxy

Returns a new instance of R10KLogProxy.



7
8
9
10
11
# File 'lib/bolt/r10k_log_proxy.rb', line 7

def initialize
  super('bolt')

  @logger = Bolt::Logger.logger(self)
end

Instance Method Details

#canonical_log(event) ⇒ Object



13
14
15
16
# File 'lib/bolt/r10k_log_proxy.rb', line 13

def canonical_log(event)
  level = to_bolt_level(event.level)
  @logger.send(level, event.data)
end

#to_bolt_level(level_num) ⇒ Object

Convert an r10k log level to a bolt log level. These correspond 1-to-1 except that r10k has debug, debug1, and debug2. The log event has the log level as an integer that we need to look up.



21
22
23
24
25
26
27
28
# File 'lib/bolt/r10k_log_proxy.rb', line 21

def to_bolt_level(level_num)
  level_str = Log4r::LNAMES[level_num]&.downcase || 'debug'
  if level_str =~ /debug/
    :debug
  else
    level_str.to_sym
  end
end