Class: Ramaze::Logger::Syslog
- Inherits:
-
Object
- Object
- Ramaze::Logger::Syslog
- Includes:
- Ramaze::Logging
- Defined in:
- lib/ramaze/log/syslog.rb
Overview
Logger class for writing to syslog. It is a very thin wrapper around the Syslog library.
Constant Summary collapse
- ALIASES =
Hash containing various method aliases. Rbx and Jruby don’t seem to like the combination of alias() and module_function() so this works around that.
{:dev => :debug, :warn => :warning, :error => :err}
Instance Method Summary collapse
-
#initialize(*args) ⇒ Syslog
constructor
Open the syslog library, if it is already open, we reopen it using the new argument list.
-
#inspect ⇒ Object
Has to call the modules singleton-method.
-
#log(tag, *messages) ⇒ Object
Just sends all messages received to ::Syslog We simply return if the log was closed for some reason, this behavior was copied from Informer.
Methods included from Ramaze::Logging
#debug, #debug?, #dev, #error, #info, #shutdown, #tag_log, #warn
Constructor Details
#initialize(*args) ⇒ Syslog
Open the syslog library, if it is already open, we reopen it using the new argument list. The argument list is passed on to the Syslog library so please check that, and man syslog for detailed information.
There are 3 parameters:
-
ident: The identification used in the log file, defaults to $0
-
options: defaults to Syslog::LOG_PID | Syslog::LOG_CONS
-
facility: defaults to Syslog::LOG_USER
32 33 34 35 |
# File 'lib/ramaze/log/syslog.rb', line 32 def initialize(*args) ::Syslog.close if ::Syslog.opened? ::Syslog.open(*args) end |
Instance Method Details
#inspect ⇒ Object
Has to call the modules singleton-method.
57 58 59 |
# File 'lib/ramaze/log/syslog.rb', line 57 def inspect ::Syslog.inspect end |
#log(tag, *messages) ⇒ Object
Just sends all messages received to ::Syslog We simply return if the log was closed for some reason, this behavior was copied from Informer. We do not handle levels here. This will be done by the syslog daemon based on it’s configuration.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ramaze/log/syslog.rb', line 42 def log(tag, *) return if !::Syslog.opened? tag = tag.to_sym if ALIASES.key?(tag) tag = ALIASES[tag] end = .map {|m| m.gsub(/(%[^m])/,'%\1')} ::Syslog.send(tag, *) end |