lib/ztk/logger.rb in ztk-0.0.3 vs lib/ztk/logger.rb in ztk-0.0.4

- old
+ new

@@ -39,11 +39,11 @@ def parse_caller(at) if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at file = Regexp.last_match[1] line = Regexp.last_match[2] method = Regexp.last_match[3] - "#{File.basename(file)}:#{line}:#{method} | " + "#{File.basename(file)}:#{line}:#{method}|" else "" end end @@ -52,12 +52,12 @@ def add(severity, message = nil, progname = nil, &block) return if (@level > severity) called_by = parse_caller(caller[1]) msg = (block && block.call) - return if (msg.nil? || msg.strip.empty?) - message = [message, progname, msg].delete_if{|i| i == nil}.join(": ") - message = "%19s.%06d+%05d|%5s|%s%s\n" % [Time.now.utc.strftime("%Y-%m-%d %H:%M:%S"), Time.now.utc.usec, Process.pid, SEVERITIES[severity], called_by, message] + (msg.nil? || msg.strip.empty?) and return + message = [message, progname, msg].delete_if{ |i| i.nil? }.join(": ") + message = "%19s.%06d|%05d|%5s|%s%s\n" % [Time.now.utc.strftime("%Y-%m-%d|%H:%M:%S"), Time.now.utc.usec, Process.pid, SEVERITIES[severity], called_by, message] @logdev.write(message) true end