Class: Log4r::SyslogOutputter

### Home Classes Methods

### In Files

- lib/log4r/outputter/syslogoutputter.rb

### Parent

Log4r::Outputter

### Methods

- ::new
- #close
- #closed?
- #get_levels_map
- #map_levels_by_name_to_syslog

### Included Modules

- Syslog::Constants

### Files

- GDC
- MDC
- NDC
- configurator
- emailoutputter
- formatter
- log4jxmlformatter
- log4r
- logger
- logserver
- outputter
- patternformatter
- scribeoutputter
- syslogoutputter
- win32eventoutputter
- yamlconfigurator

### Class/Module Index

Quicksearch

- Log4r
- Log4r::BasicFormatter
- Log4r::ConfigError
- Log4r::Configurator
- Log4r::DateFileOutputter
- Log4r::DefaultFormatter
- Log4r::EmailOutputter
- Log4r::FileOutputter
- Log4r::Formatter
- Log4r::GDC
- Log4r::IOOutputter
- Log4r::Log4jXmlFormatter
- Log4r::Log4rTools
- Log4r::LogEvent
- Log4r::LogServer
- Log4r::Logger
- Log4r::MDC
- Log4r::NDC
- Log4r::ObjectFormatter
- Log4r::Outputter
- Log4r::PatternFormatter
- Log4r::RemoteOutputter
- Log4r::RollingFileOutputter
- Log4r::RootLogger
- Log4r::ScribeOutputter
- Log4r::SimpleFormatter
- Log4r::StderrOutputter
- Log4r::StdoutOutputter
- Log4r::SyslogOutputter
- Log4r::UDPOutputter
- Log4r::YamlConfigurator
- REXML
- Object

No matching classes.

# Log4r::SyslogOutputter

### Constants

SYSLOG_LEVELS_MAP

  maps default log4r levels to syslog priorities (logevents never see ALL and OFF) SYSLOG Levels are:

      "DEBUG"  => Syslog::LOG_DEBUG
      "INFO"   => Syslog::LOG_INFO
      "NOTICE" => Syslog::LOG_NOTICE
      "WARN"   => Syslog::LOG_WARN
      "ERROR"  => Syslog::LOG_ERROR
      "FATAL"  => Syslog::LOG_FATAL
      "ALERT"  => Syslog::LOG_ALERT
      "EMERG"  => Syslog::LOG_EMERG

SYSLOG_LOG4R_MAP

  mapping from Log4r default levels to syslog, by string name "DEBUG" => "DEBUG"

      "INFO"   => "INFO"
      "WARN"   => "WARN"
      "ERROR"  => "ERROR"
      "FATAL"  => "FATAL"

### Public Class Methods

new(_name, hash={}) click to toggle source

There are 3 hash arguments

`:ident`

  syslog ident, defaults to _name

`:logopt`

  syslog logopt, defaults to LOG_PID | LOG_CONS

`:facility`

  syslog facility, defaults to LOG_USER

    # File lib/log4r/outputter/syslogoutputter.rb, line 64
    def initialize(_name, hash={})
      super(_name, hash)
      ident = (hash[:ident] or hash['ident'] or _name)
      logopt = (hash[:logopt] or hash['logopt'] or LOG_PID | LOG_CONS).to_i
      facility = (hash[:facility] or hash['facility'] or LOG_USER).to_i
      map_levels_by_name_to_syslog()
      if ( Syslog.opened? ) then
        Logger.log_internal { "Syslog already initialized, to alter, " +
          "you must close first"}
      end
      @syslog = ( Syslog.opened? ) ? Syslog : Syslog.open(ident, logopt, facility)
    end

### Public Instance Methods

close() click to toggle source

    # File lib/log4r/outputter/syslogoutputter.rb, line 81
    def close
      @syslog.close unless @syslog.nil?
      @level = OFF
      OutputterFactory.create_methods(self)
      Logger.log_internal {"Outputter '#{@name}' closed Syslog and set to OFF"}
    end

closed?() click to toggle source

    # File lib/log4r/outputter/syslogoutputter.rb, line 77
    def closed?
      return !@syslog.opened?
    end

get_levels_map() click to toggle source

    # File lib/log4r/outputter/syslogoutputter.rb, line 110
    def get_levels_map()
      return @levels_map
    end

map_levels_by_name_to_syslog( lmap = SYSLOG_LOG4R_MAP ) click to toggle source

A single hash argument that maps custom names to syslog names

`levels_map`

  A map that will create a linkage between levels in a hash and underlying syslog levels. By default, these are direct mapping of the log4r levels (e.g. "DEBUG" => "DEBUG") If you have defined your own custom levels, you should provide this underlying mapping, otherwise all messages will be mapped to the underlying syslog level of INFO by default. e.g. You have created custom levels called: `Configurator.custom_levels "HIGH", "MEDIUM", "LOW"` To map these to 'equivilent' syslog levels, after instantiatin a syslogoutputter: `SyslogOutputter.map_levels_by_name_to_syslog( { "HIGH" => "ALERT", "MEDIUM" => "WARN", "LOW" => "INFO" } )`

    # File lib/log4r/outputter/syslogoutputter.rb, line 106
    def map_levels_by_name_to_syslog( lmap = SYSLOG_LOG4R_MAP )
      @levels_map = lmap
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.