lib/syslogger.rb in syslogger-1.2.4 vs lib/syslogger.rb in syslogger-1.2.5
- old
+ new
@@ -1,11 +1,11 @@
require 'syslog'
require 'logger'
class Syslogger
- VERSION = "1.2.4"
+ VERSION = "1.2.5"
attr_reader :level, :ident, :options, :facility
MAPPING = {
Logger::DEBUG => Syslog::LOG_DEBUG,
@@ -45,10 +45,13 @@
@facility = facility
@level = Logger::INFO
end
%w{debug info warn error fatal unknown}.each do |logger_method|
- define_method logger_method.to_sym do |message|
+ # Accepting *args as message could be nil.
+ # Default params not supported in ruby 1.8.7
+ define_method logger_method.to_sym do |*args, &block|
+ message = args.first || block && block.call
add(Logger.const_get(logger_method.upcase), message)
end
unless logger_method == 'unknown'
define_method "#{logger_method}?".to_sym do