Parent

Files

Class/Module Index [+]

Quicksearch

Logger::SyslogFormatter

Adds some default information to syslog messages. Log format:

[Time.mSec] [SeverityLabel]: message

Constants

Format

Attributes

datetime_format[RW]

Public Class Methods

new() click to toggle source
# File lib/syslog-formatter.rb, line 10
def initialize
  @datetime_format = nil
end

Public Instance Methods

call(severity, time, progname, msg) click to toggle source
# File lib/syslog-formatter.rb, line 14
def call(severity, time, progname, msg)
  Format % [format_datetime(time), severity, msg2str(msg)]
end

Protected Instance Methods

format_datetime(time) click to toggle source
# File lib/syslog-formatter.rb, line 20
def format_datetime(time)
  if @datetime_format.nil?
    time.strftime("%H:%M:%S.") << "%06d " % time.usec
  else
    time.strftime(@datetime_format)
  end
end
msg2str(msg) click to toggle source
# File lib/syslog-formatter.rb, line 28
def msg2str(msg)
  case msg
  when ::String
    msg
  when ::Exception
    "#{ msg.message } (#{ msg.class })\n" <<
      (msg.backtrace || []).join("\n")
  else
    msg.inspect
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.