lib/syslogger.rb in syslogger-1.2.6 vs lib/syslogger.rb in syslogger-1.2.7

- old
+ new

@@ -1,11 +1,11 @@ require 'syslog' require 'logger' class Syslogger - VERSION = "1.2.6" + VERSION = "1.2.7" attr_reader :level, :ident, :options, :facility MAPPING = { Logger::DEBUG => Syslog::LOG_DEBUG, @@ -48,18 +48,24 @@ %w{debug info warn error fatal unknown}.each do |logger_method| # 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| + return true if @level > Logger.const_get(logger_method.upcase) 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 @level <= Logger.const_get(logger_method.upcase) end end + end + + # Log a message at the Logger::INFO level. Useful for use with Rack::CommonLogger + def write(msg) + add(Logger::INFO, msg) end # Logs a message at the Logger::INFO level. def <<(msg) add(Logger::INFO, msg)