Class: MCollective::Util::Playbook::Playbook_Logger
- Inherits:
-
Logger::Console_logger
- Object
- Logger::Base
- Logger::Console_logger
- MCollective::Util::Playbook::Playbook_Logger
- Defined in:
- lib/mcollective/util/playbook/playbook_logger.rb
Instance Attribute Summary collapse
-
#scope ⇒ Object
writeonly
Sets the attribute scope.
Attributes inherited from Logger::Base
Instance Method Summary collapse
-
#initialize(playbook) ⇒ Playbook_Logger
constructor
A new instance of Playbook_Logger.
- #log(level, from, msg, normal_output = $stderr, last_resort_output = $stderr) ⇒ Object
- #should_show? ⇒ 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) ⇒ Playbook_Logger
Returns a new instance of Playbook_Logger.
9 10 11 12 13 14 |
# File 'lib/mcollective/util/playbook/playbook_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/playbook_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 |
# File 'lib/mcollective/util/playbook/playbook_logger.rb', line 20 def log(level, from, msg, normal_output=$stderr, last_resort_output=$stderr) if @playbook.loglevel != "debug" if should_show? console_from = "%s#%-25s" % [@playbook.name, @playbook.context] else level = :debug end end if @known_levels.index(level) >= @known_levels.index(@active_level) r_time = Time.now s_time = r_time.strftime("%H:%M:%S") @report.append_log(r_time, level, from, msg) normal_output.puts("%s %s: %s %s" % [colorize(level, level[0].capitalize), s_time, console_from, msg]) end rescue last_resort_output.puts("%s: %s" % [level, msg]) end |
#should_show? ⇒ Boolean
41 42 43 |
# File 'lib/mcollective/util/playbook/playbook_logger.rb', line 41 def should_show? !caller(1..5).grep(/playbook/).empty? end |
#start ⇒ Object
16 17 18 |
# File 'lib/mcollective/util/playbook/playbook_logger.rb', line 16 def start set_level(@playbook.loglevel.intern) end |