Parent

Class Index [+]

Quicksearch

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]

(Not documented)

Public Class Methods

new() click to toggle source

(Not documented)

    # File lib/mcollective/logger/base.rb, line 14
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, line 28
28:       def cycle_level
29:         lvl = get_next_level
30:         set_level(lvl)
31: 
32:         log(lvl, "", "Logging level is now #{lvl.to_s.upcase}")
33:       end
set_level(level) click to toggle source

Sets a new level and record it in @active_level

    # File lib/mcollective/logger/base.rb, line 36
36:       def set_level(level)
37:         set_logging_level(level)
38:         @active_level = level.to_sym
39:       end
should_log?(level) click to toggle source

(Not documented)

    # File lib/mcollective/logger/base.rb, line 23
23:       def should_log?(level)
24:         @known_levels.index(level) >= @known_levels.index(@active_level)
25:       end

Private Instance Methods

get_next_level() click to toggle source

Gets the next level in the list, cycles down to the firt once it reaches the end

    # File lib/mcollective/logger/base.rb, line 49
49:       def get_next_level
50:         # if all else fails, always go to debug mode
51:         nextlvl = :debug
52: 
53:         if @known_levels.index(@active_level) == (@known_levels.size - 1)
54:           nextlvl = @known_levels.first
55:         else
56:           idx = @known_levels.index(@active_level) + 1
57:           nextlvl = @known_levels[idx]
58:         end
59: 
60:         nextlvl
61:       end
log(level, from, msg) click to toggle source

(Not documented)

    # File lib/mcollective/logger/base.rb, line 68
68:       def log(level, from, msg)
69:         raise "The logging class did not supply a log method"
70:       end
map_level(level) click to toggle source

(Not documented)

    # File lib/mcollective/logger/base.rb, line 42
42:       def map_level(level)
43:         raise "Logger class do not know how to handle #{level} messages" unless valid_levels.include?(level.to_sym)
44: 
45:         valid_levels[level.to_sym]
46:       end
start() click to toggle source

(Not documented)

    # File lib/mcollective/logger/base.rb, line 72
72:       def start
73:         raise "The logging class did not supply a start method"
74:       end
valid_levels() click to toggle source

Abstract methods to ensure the logging implimentations supply what they should

    # File lib/mcollective/logger/base.rb, line 64
64:       def valid_levels
65:         raise "The logging class did not supply a valid_levels method"
66:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.