Class Daemons::SyslogIO
In: lib/daemons/syslogio.rb
Parent: Object

This is a simple class meant to allow using syslog through an IO-like object. Code borrowed from github.com/phemmer/ruby-syslogio

The usage is simple:

    require 'syslogio'
    $stdout = SyslogIO.new("myapp", :local0, :info, $stdout)
    $stderr = SyslogIO.new("myapp", :local0, :err, $stderr)
    $stdout.puts "This is a message"
    $stderr.puts "This is an error"
    raise StandardError, 'This will get written through the SyslogIO for $stderr'

Methods

<<   crit   debug   emerg   error   fatal   flush   info   isatty   log   new   noop   notice   notify   puts   reopen   sub_add   sync=   syslog_constant   syslog_constant_sym   syslog_facility   syslog_level   syslog_option   syswrite   warn   write  

Attributes

sync  [R]  Indicates whether synchonous IO is enabled. @return [Boolean]

Public Class methods

Creates a new object. You can have as many SyslogIO objects as you like. However because they all share the same syslog connection, some parameters are shared. The identifier shared among all SyslogIO objects, and is set to the value of the last one created. The Syslog options are merged together as a combination of all objects. The facility and level are distinct between each though. If an IO object is provided as an argument, any text written to the SyslogIO object will also be passed through to that IO object.

@param identifier [String] Identifier @param facility [Fixnum<Syslog::Facility>] Syslog facility @param level [Fixnum<Syslog::Level>] Syslog level @param option [Fixnum<Syslog::Options>] Syslog option @param passthrough [IO] IO passthrough

@!visibility private

@!visibility private

@!visibility private

@!visibility private

@!visibility private

Public Instance methods

<<(text)

Alias for write

Log at the critical level

Shorthand for {log}(text, Syslog::LOG_CRIT)

Log at the debug level

Shorthand for {log}(text, Syslog::LOG_DEBUG)

Log at the emergency level

Shorthand for {log}(text, Syslog::LOG_EMERG)

Log at the error level

Shorthand for {log}(text, Syslog::LOG_ERR)

fatal(text)

Alias for crit

Immediately flush any buffered data

Log at the info level

Shorthand for {log}(text, Syslog::LOG_INFO)

Write a complete line at the specified log level

Similar to {puts} but allows changing the log level for just this one message

@!visibility private

Log at the notice level

Shorthand for {log}(text, Syslog::LOG_NOTICE)

notify(text)

Alias for notice

Log a complete line

Similar to {write} but appends a newline if not present.

reopen(*args)

Alias for noop

Add a substitution rule

These substitutions will be applied to each line before it is logged. This can be useful if some other gem is generating log content and you want to change the formatting. @param regex [Regex]

Enable or disable synchronous IO (buffering).

When false (default), output will be line buffered. For syslog this is optimal so the log entries are complete lines.

Write to syslog directly, bypassing buffering if enabled.

Log at the warning level

Shorthand for {log}(text, Syslog::LOG_WARNING)

Write to syslog respecting the behavior of the {sync} setting.

[Validate]