Class | MCollective::Logger::Console_logger |
In: |
lib/mcollective/logger/console_logger.rb
|
Parent: | Base |
Impliments a syslog based logger using the standard ruby syslog class
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 => "[31m", 41: :fatal => "[31m", 42: :warn => "[33m", 43: :info => "[32m", 44: :reset => "[0m"} 45: 46: if colorize 47: return colors[level] || "" 48: else 49: return "" 50: end 51: end
# File lib/mcollective/logger/console_logger.rb, line 22 22: def log(level, from, msg) 23: if @known_levels.index(level) >= @known_levels.index(@active_level) 24: time = Time.new.strftime("%Y/%m/%d %H:%M:%S") 25: lvltxt = colorize(level, level) 26: STDERR.puts("#{lvltxt} #{time}: #{from} #{msg}") 27: end 28: rescue 29: # if this fails we probably cant show the user output at all, 30: # STDERR it as last resort 31: STDERR.puts("#{level}: #{msg}") 32: end
# File lib/mcollective/logger/console_logger.rb, line 10 10: def set_logging_level(level) 11: # nothing to do here, we ignore high levels when we log 12: end
# File lib/mcollective/logger/console_logger.rb, line 5 5: def start 6: config = Config.instance 7: set_level(config.loglevel.to_sym) 8: end