lib/syslogger.rb in syslogger-1.4.2 vs lib/syslogger.rb in syslogger-1.5.0
- old
+ new
@@ -2,11 +2,11 @@
require 'logger'
require 'thread'
class Syslogger
- VERSION = "1.4.2"
+ VERSION = "1.5.0"
attr_reader :level, :ident, :options, :facility, :max_octets
MAPPING = {
Logger::DEBUG => Syslog::LOG_DEBUG,
@@ -79,14 +79,18 @@
# +message+:: the message string.
# If nil, the method will call the block and use the result as the message string.
# If both are nil or no block is given, it will use the progname as per the behaviour of both the standard Ruby logger, and the Rails BufferedLogger.
# +progname+:: optionally, overwrite the program name that appears in the log message.
def add(severity, message = nil, progname = nil, &block)
+ if message.nil? && block.nil? && !progname.nil?
+ message, progname = progname, nil
+ end
progname ||= @ident
+
@mutex.synchronize do
Syslog.open(progname, @options, @facility) do |s|
s.mask = Syslog::LOG_UPTO(MAPPING[@level])
- communication = clean(message || (block && block.call) || progname)
+ communication = clean(message || block && block.call)
if self.max_octets
buffer = ""
communication.bytes do |byte|
buffer.concat(byte)
if buffer.bytesize >= self.max_octets