Parent

Class/Module Index [+]

Quicksearch

MCollective::Logger::File_logger

Impliments a file based logger using the standard ruby logger class

To configure you should set:

- config.logfile
- config.keeplogs defaults to 2097152
- config.max_log_size defaults to 5

Public Instance Methods

log(level, from, msg) click to toggle source
# File lib/mcollective/logger/file_logger.rb, line 37
def log(level, from, msg)
  @logger.add(map_level(level)) { "#{from} #{msg}" }
rescue
  # if this fails we probably cant show the user output at all,
  # STDERR it as last resort
  STDERR.puts("#{level}: #{msg}")
end
set_logging_level(level) click to toggle source
# File lib/mcollective/logger/file_logger.rb, line 22
def set_logging_level(level)
  @logger.level = map_level(level)
rescue Exception => e
  @logger.level = ::Logger::DEBUG
  log(:error, "", "Could not set logging to #{level} using debug instead: #{e.class} #{e}")
end
start() click to toggle source
# File lib/mcollective/logger/file_logger.rb, line 13
def start
  config = Config.instance

  @logger = ::Logger.new(config.logfile, config.keeplogs, config.max_log_size)
  @logger.formatter = ::Logger::Formatter.new

  set_level(config.loglevel.to_sym)
end
valid_levels() click to toggle source
# File lib/mcollective/logger/file_logger.rb, line 29
def valid_levels
  {:info  => ::Logger::INFO,
    :warn  => ::Logger::WARN,
    :debug => ::Logger::DEBUG,
    :fatal => ::Logger::FATAL,
    :error => ::Logger::ERROR}
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.