class ThreadFormatter
Constants
- FORMAT
Attributes
datetime_format[RW]
Public Class Methods
layout()
click to toggle source
get pattern layout for Logging::Logger
# File lib/common/thread_formatter.rb, line 5 def self.layout Logging.layouts.pattern(:pattern => "%.1l, [%d #%p] [%T] %5l -- %c: %m\n") end
new()
click to toggle source
# File lib/common/thread_formatter.rb, line 11 def initialize @datetime_format = nil end
Public Instance Methods
call(severity, time, progname, msg)
click to toggle source
# File lib/common/thread_formatter.rb, line 15 def call(severity, time, progname, msg) thread_name = Thread.current[:name] || "0x#{Thread.current.object_id.to_s(16)}" FORMAT % [severity[0..0], format_datetime(time), $$, thread_name, severity, progname, msg2str(msg)] end
Private Instance Methods
format_datetime(time)
click to toggle source
# File lib/common/thread_formatter.rb, line 23 def format_datetime(time) if @datetime_format.nil? time.strftime("%Y-%m-%dT%H:%M:%S.") << "%06d " % time.usec else time.strftime(@datetime_format) end end
msg2str(msg)
click to toggle source
# File lib/common/thread_formatter.rb, line 31 def msg2str(msg) case msg when ::String msg when ::Exception "#{ msg.message } (#{ msg.class })\n" << (msg.backtrace || []).join("\n") else msg.inspect end end