Parent

Class Index [+]

Quicksearch

MCollective::Logger::Console_logger

Implements a syslog based logger using the standard ruby syslog class

Public Instance Methods

color(level) click to toggle source

Set some colors for various logging levels, will honor the color configuration option and return nothing if its configured not to

    # File lib/mcollective/logger/console_logger.rb, line 37
37:       def color(level)
38:         colorize = Config.instance.color
39: 
40:         colors = {:error => Util.color(:red),
41:                   :fatal => Util.color(:red),
42:                   :warn  => Util.color(:yellow),
43:                   :info  => Util.color(:green),
44:                   :reset => Util.color(:reset)}
45: 
46:         if colorize
47:           return colors[level] || ""
48:         else
49:           return ""
50:         end
51:       end
colorize(level, msg) click to toggle source

Helper to return a string in specific color

    # File lib/mcollective/logger/console_logger.rb, line 54
54:       def colorize(level, msg)
55:         "%s%s%s" % [ color(level), msg, color(:reset) ]
56:       end
log(level, from, msg, normal_output=STDERR, last_resort_output=STDERR) click to toggle source

(Not documented)

    # File lib/mcollective/logger/console_logger.rb, line 24
24:       def log(level, from, msg, normal_output=STDERR, last_resort_output=STDERR)
25:         time = Time.new.strftime("%Y/%m/%d %H:%M:%S")
26: 
27:         normal_output.puts("%s %s: %s %s" % [colorize(level, level), time, from, msg])
28:       rescue
29:         # if this fails we probably cant show the user output at all,
30:         # STDERR it as last resort
31:         last_resort_output.puts("#{level}: #{msg}")
32:       end
set_logging_level(level) click to toggle source

(Not documented)

    # File lib/mcollective/logger/console_logger.rb, line 12
12:       def set_logging_level(level)
13:         # nothing to do here, we ignore high levels when we log
14:       end
start() click to toggle source

(Not documented)

    # File lib/mcollective/logger/console_logger.rb, line 5
 5:       def start
 6:         set_level(:info)
 7: 
 8:         config = Config.instance
 9:         set_level(config.loglevel.to_sym) if config.configured
10:       end
valid_levels() click to toggle source

(Not documented)

    # File lib/mcollective/logger/console_logger.rb, line 16
16:       def valid_levels
17:         {:info  => :info,
18:          :warn  => :warning,
19:          :debug => :debug,
20:          :fatal => :crit,
21:          :error => :err}
22:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.