lib/ztk/logger.rb
# Writes a log message if the current log level is at or below the supplied
# severity.
#
# @param [Constant] severity Log level severity.
# @param [String] message Optional message to prefix the log entry with.
# @param [String] progname Optional name of the program to prefix the log
#   entry with.
# @yieldreturn [String] The block should return the desired log message.
Writes a log message if the current log level is at or below the supplied
severity.
Writes a log message if the current log level is at or below the supplied severity .
def add(severity, message=nil, progname=nil, shift=0, &block)
      return if (@level > severity)
      message = block.call if message.nil? && block_given?
      return if message.nil?
      called_by = parse_caller(caller[1+shift])
      message = [message.chomp, progname].flatten.compact.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(ZTK::ANSI.uncolor(message))
      @logdev.respond_to?(:flush) and @logdev.flush
      true
    end
def add ( severity , message = nil , progname = nil , shift = 0 , & block ) return if ( @level > severity ) message = block . call if message . nil? && block_given? return if message . nil? called_by = parse_caller ( caller [ 1 + shift ] ) message = [ message . chomp , progname ] . flatten . compact . 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 ( ZTK :: ANSI . uncolor ( message ) ) @logdev . respond_to? ( :flush ) and @logdev . flush true end
Writes a log message if the current log level is at or below the supplied
severity.
Writes a log message if the current log level is at or below the supplied severity .
The block should return the desired log message.
The block should return the desired log message .
String
severity
<not_specific>
message
<not_specific>
progname
<not_specific>
shift
<not_specific>
block
<not_specific>
<not_specific>
progname Optional name of the program to prefix the log entry with.
progname Optional name of the program to prefix the log entry with .