Class: MCollective::Util::Playbook::Puppet_Logger
- Inherits:
-
Logger::Console_logger
- Object
- Logger::Base
- Logger::Console_logger
- MCollective::Util::Playbook::Puppet_Logger
- Defined in:
- lib/mcollective/util/playbook/puppet_logger.rb
Instance Attribute Summary collapse
-
#scope ⇒ Object
writeonly
Sets the attribute scope.
Attributes inherited from Logger::Base
Instance Method Summary collapse
-
#initialize(playbook) ⇒ Puppet_Logger
constructor
A new instance of Puppet_Logger.
- #log(level, from, msg, normal_output = $stderr, last_resort_output = $stderr) ⇒ Object
- #should_show?(level) ⇒ Boolean
- #start ⇒ Object
Methods inherited from Logger::Console_logger
#color, #colorize, #set_logging_level, #valid_levels
Methods inherited from Logger::Base
#cycle_level, #reopen, #set_level
Constructor Details
#initialize(playbook) ⇒ Puppet_Logger
Returns a new instance of Puppet_Logger.
9 10 11 12 13 14 |
# File 'lib/mcollective/util/playbook/puppet_logger.rb', line 9 def initialize(playbook) @playbook = playbook @report = playbook.report super() end |
Instance Attribute Details
#scope=(value) ⇒ Object (writeonly)
Sets the attribute scope
7 8 9 |
# File 'lib/mcollective/util/playbook/puppet_logger.rb', line 7 def scope=(value) @scope = value end |
Instance Method Details
#log(level, from, msg, normal_output = $stderr, last_resort_output = $stderr) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mcollective/util/playbook/puppet_logger.rb', line 20 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 |
#should_show?(level) ⇒ Boolean
43 44 45 46 47 |
# File 'lib/mcollective/util/playbook/puppet_logger.rb', line 43 def should_show?(level) return true unless level == :info !caller(2..5).grep(/playbook/).empty? end |
#start ⇒ Object
16 17 18 |
# File 'lib/mcollective/util/playbook/puppet_logger.rb', line 16 def start set_level(@playbook.loglevel.intern) end |