Class: ThreadFormatter
- Inherits:
-
Object
- Object
- ThreadFormatter
- Defined in:
- lib/common/thread_formatter.rb
Constant Summary collapse
- FORMAT =
"%s, [%s#%d] [%s] %5s -- %s: %s\n"
Instance Attribute Summary collapse
-
#datetime_format ⇒ Object
Returns the value of attribute datetime_format.
Class Method Summary collapse
-
.layout ⇒ Object
get pattern layout for Logging::Logger.
Instance Method Summary collapse
- #call(severity, time, progname, msg) ⇒ Object
-
#initialize ⇒ ThreadFormatter
constructor
A new instance of ThreadFormatter.
Constructor Details
#initialize ⇒ ThreadFormatter
Returns a new instance of ThreadFormatter.
11 12 13 |
# File 'lib/common/thread_formatter.rb', line 11 def initialize @datetime_format = nil end |
Instance Attribute Details
#datetime_format ⇒ Object
Returns the value of attribute datetime_format.
9 10 11 |
# File 'lib/common/thread_formatter.rb', line 9 def datetime_format @datetime_format end |
Class Method Details
.layout ⇒ Object
get pattern layout for Logging::Logger
5 6 7 |
# File 'lib/common/thread_formatter.rb', line 5 def self.layout Logging.layouts.pattern(:pattern => "%.1l, [%d #%p] [%T] %5l -- %c: %m\n") end |
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
15 16 17 18 19 |
# 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 |