class MCollective::Logger::Base - mcollective version 2.12.5

# class MCollective::Logger::Base

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

### Attributes

active_level[R]

### Public Class Methods

new() click to toggle source

       # File lib/mcollective/logger/base.rb
    14 def initialize
    15   @known_levels = [:debug, :info, :warn, :error, :fatal]
    16
    17   # Sanity check the class that impliments the logging
    18   @known_levels.each do |lvl|
    19     raise "Logger class did not specify a map for #{lvl}" unless valid_levels.include?(lvl)
    20   end
    21 end

### Public Instance Methods

cycle_level() click to toggle source

Figures out the next level and sets it

       # File lib/mcollective/logger/base.rb
    24 def cycle_level
    25   lvl = get_next_level
    26   set_level(lvl)
    27
    28   log(lvl, "", "Logging level is now #{lvl.to_s.upcase}")
    29 end

log(level, from, msg) click to toggle source

       # File lib/mcollective/logger/base.rb
    41 def log(level, from, msg)
    42   raise "The logging class did not supply a log method"
    43 end

reopen() click to toggle source

       # File lib/mcollective/logger/base.rb
    45 def reopen
    46   # reopen may not make sense to all Loggers, but we expect it of the API
    47 end

set_level(level) click to toggle source

Sets a new level and record it in @active_level

       # File lib/mcollective/logger/base.rb
    32 def set_level(level)
    33   set_logging_level(level)
    34   @active_level = level.to_sym
    35 end

start() click to toggle source

       # File lib/mcollective/logger/base.rb
    37 def start
    38   raise "The logging class did not supply a start method"
    39 end