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'
sync | [R] | Indicates whether synchonous IO is enabled. @return [Boolean] |
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
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.