# 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, line 42
    def log(level, from, msg)
      if @known_levels.index(level) >= @known_levels.index(@active_level)
        Syslog.send(map_level(level), "#{from} #{msg}")
      end
    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/syslog_logger.rb, line 30
    def set_logging_level(level)
      # noop
    end

start() click to toggle source

    # File lib/mcollective/logger/syslog_logger.rb, line 9
    def start
      config = Config.instance

      facility = syslog_facility(config.logfacility)
      level = config.loglevel.to_sym

      Syslog.close if Syslog.opened?
      Syslog.open(File.basename($0), 3, facility)

      set_level(level)
    end

syslog_facility(facility) click to toggle source

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

valid_levels() click to toggle source

    # File lib/mcollective/logger/syslog_logger.rb, line 34
    def valid_levels
      {:info  => :info,
       :warn  => :warning,
       :debug => :debug,
       :fatal => :crit,
       :error => :err}
    end