Sha256: 45965525cbe1f1fa3b1b417de4ea735bc33a0ae8d7c715a3c285bd84ccd6387b

Contents?: true

Size: 742 Bytes

Versions: 60

Compression:

Stored size: 742 Bytes

Contents

# frozen_string_literal: true

require 'log4r/outputter/outputter'

module Bolt
  class R10KLogProxy < Log4r::Outputter
    def initialize
      super('bolt')

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

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

    # 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.
    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
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
bolt-4.0.0 lib/bolt/r10k_log_proxy.rb
bolt-3.29.0 lib/bolt/r10k_log_proxy.rb
bolt-3.28.0 lib/bolt/r10k_log_proxy.rb
bolt-3.27.4 lib/bolt/r10k_log_proxy.rb
bolt-3.27.2 lib/bolt/r10k_log_proxy.rb
bolt-3.27.1 lib/bolt/r10k_log_proxy.rb
bolt-3.26.2 lib/bolt/r10k_log_proxy.rb
bolt-3.26.1 lib/bolt/r10k_log_proxy.rb
bolt-3.25.0 lib/bolt/r10k_log_proxy.rb
bolt-3.24.0 lib/bolt/r10k_log_proxy.rb
bolt-3.23.1 lib/bolt/r10k_log_proxy.rb
bolt-3.23.0 lib/bolt/r10k_log_proxy.rb
bolt-3.22.1 lib/bolt/r10k_log_proxy.rb
bolt-3.22.0 lib/bolt/r10k_log_proxy.rb
bolt-3.21.0 lib/bolt/r10k_log_proxy.rb
bolt-3.20.0 lib/bolt/r10k_log_proxy.rb
bolt-3.19.0 lib/bolt/r10k_log_proxy.rb
bolt-3.18.0 lib/bolt/r10k_log_proxy.rb
bolt-3.17.0 lib/bolt/r10k_log_proxy.rb
bolt-3.16.1 lib/bolt/r10k_log_proxy.rb