Class: MCollective::Logger::Base
- Inherits:
-
Object
- Object
- MCollective::Logger::Base
- Defined in:
- lib/mcollective/logger/base.rb
Overview
A base class for logging providers.
Logging providers should provide the following:
* start - all you need to do to setup your logging
* set_logging_level - set your logging to :info, :warn, etc
* valid_levels - a hash of maps from :info to your internal level name
* log - what needs to be done to log a specific message
Direct Known Subclasses
Instance Attribute Summary collapse
-
#active_level ⇒ Object
readonly
Returns the value of attribute active_level.
Instance Method Summary collapse
-
#cycle_level ⇒ Object
Figures out the next level and sets it.
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #log(level, from, msg) ⇒ Object
- #reopen ⇒ Object
-
#set_level(level) ⇒ Object
Sets a new level and record it in @active_level.
- #start ⇒ Object
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
14 15 16 17 18 19 20 21 |
# File 'lib/mcollective/logger/base.rb', line 14 def initialize @known_levels = [:debug, :info, :warn, :error, :fatal] # Sanity check the class that impliments the logging @known_levels.each do |lvl| raise "Logger class did not specify a map for #{lvl}" unless valid_levels.include?(lvl) end end |
Instance Attribute Details
#active_level ⇒ Object (readonly)
Returns the value of attribute active_level.
12 13 14 |
# File 'lib/mcollective/logger/base.rb', line 12 def active_level @active_level end |
Instance Method Details
#cycle_level ⇒ Object
Figures out the next level and sets it
24 25 26 27 28 29 |
# File 'lib/mcollective/logger/base.rb', line 24 def cycle_level lvl = get_next_level set_level(lvl) log(lvl, "", "Logging level is now #{lvl.to_s.upcase}") end |
#log(level, from, msg) ⇒ Object
41 42 43 |
# File 'lib/mcollective/logger/base.rb', line 41 def log(level, from, msg) raise "The logging class did not supply a log method" end |
#reopen ⇒ Object
45 46 47 |
# File 'lib/mcollective/logger/base.rb', line 45 def reopen # reopen may not make sense to all Loggers, but we expect it of the API end |
#set_level(level) ⇒ Object
Sets a new level and record it in @active_level
32 33 34 35 |
# File 'lib/mcollective/logger/base.rb', line 32 def set_level(level) set_logging_level(level) @active_level = level.to_sym end |
#start ⇒ Object
37 38 39 |
# File 'lib/mcollective/logger/base.rb', line 37 def start raise "The logging class did not supply a start method" end |