Sha256: c274ab4a8b94d8ff16507933b76d941084349d5aa4c153a61a9640091d24b2a8

Contents?: true

Size: 1.2 KB

Versions: 19

Compression:

Stored size: 1.2 KB

Contents

require "mcollective/logger/console_logger"

module MCollective
  module Util
    class Playbook
      class Puppet_Logger < Logger::Console_logger
        attr_writer :scope

        def initialize(playbook)
          @playbook = playbook
          @report = playbook.report

          super()
        end

        def start
          set_level(@playbook.loglevel.intern)
        end

        def log(level, from, msg, normal_output=$stderr, last_resort_output=$stderr)
          return unless should_show?(level)

          logmethod = case level
                      when :info
                        :notice
                      when :warn
                        :warning
                      when :error
                        :err
                      when :fatal
                        :crit
                      else
                        :debug
                      end

          if @scope
            Puppet::Util::Log.log_func(@scope, logmethod, [msg])
          else
            Puppet.send(logmethod, msg)
          end
        end

        def should_show?(level)
          return true unless level == :info

          !caller(2..5).grep(/playbook/).empty?
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
choria-mcorpc-support-2.26.4 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.26.3 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.26.2 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.26.1 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.26.0 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.25.3 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.25.2 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.25.1 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.25.0 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.24.4 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.24.3 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.24.2 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.24.1 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.24.0 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.23.3 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.23.2 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.23.1 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.23.0 lib/mcollective/util/playbook/puppet_logger.rb
choria-mcorpc-support-2.23.0.pre lib/mcollective/util/playbook/puppet_logger.rb