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

# class MCollective::Logger::Syslog_logger

Implements a syslog based logger using the standard ruby syslog class

### Public Instance Methods

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

       # File lib/mcollective/logger/syslog_logger.rb
    42 def log(level, from, msg)
    43   if @known_levels.index(level) >= @known_levels.index(@active_level)
    44     Syslog.send(map_level(level), "#{from} #{msg}")
    45   end
    46 rescue
    47   # if this fails we probably cant show the user output at all,
    48   # STDERR it as last resort
    49   STDERR.puts("#{level}: #{msg}")
    50 end

set_logging_level(level) click to toggle source

       # File lib/mcollective/logger/syslog_logger.rb
    30 def set_logging_level(level)
    31   # noop
    32 end

start() click to toggle source

       # File lib/mcollective/logger/syslog_logger.rb
     9 def start
    10   config = Config.instance
    11
    12   facility = syslog_facility(config.logfacility)
    13   level = config.loglevel.to_sym
    14
    15   Syslog.close if Syslog.opened?
    16   Syslog.open(File.basename($0), 3, facility)
    17
    18   set_level(level)
    19 end

syslog_facility(facility) click to toggle source

       # File lib/mcollective/logger/syslog_logger.rb
    21 def syslog_facility(facility)
    22   begin
    23     Syslog.const_get("LOG_#{facility.upcase}")
    24   rescue NameError => e
    25     STDERR.puts "Invalid syslog facility #{facility} supplied, reverting to USER"
    26     Syslog::LOG_USER
    27   end
    28 end

valid_levels() click to toggle source

       # File lib/mcollective/logger/syslog_logger.rb
    34 def valid_levels
    35   {:info  => :info,
    36    :warn  => :warning,
    37    :debug => :debug,
    38    :fatal => :crit,
    39    :error => :err}
    40 end