lib/syslogger.rb in syslogger-1.6.1 vs lib/syslogger.rb in syslogger-1.6.2

- old
+ new

@@ -2,11 +2,11 @@ require 'logger' require 'thread' class Syslogger - VERSION = "1.6.1" + VERSION = "1.6.2" attr_reader :level, :ident, :options, :facility, :max_octets attr_accessor :formatter MAPPING = { @@ -38,10 +38,11 @@ # Usage: # logger = Syslogger.new("my_app", Syslog::LOG_PID | Syslog::LOG_CONS, Syslog::LOG_LOCAL0) # logger.level = Logger::INFO # use Logger levels # logger.warn "warning message" # logger.debug "debug message" + # logger.info "my_subapp" { "Some lazily computed message" } # def initialize(ident = $0, options = Syslog::LOG_PID | Syslog::LOG_CONS, facility = nil) @ident = ident @options = options || (Syslog::LOG_PID | Syslog::LOG_CONS) @facility = facility @@ -54,12 +55,12 @@ %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) + severity = Logger.const_get(logger_method.upcase) + return true if @level > severity + add(severity, nil, args.first, &block) end unless logger_method == 'unknown' define_method "#{logger_method}?".to_sym do @level <= Logger.const_get(logger_method.upcase)