Class: ThreadFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/common/thread_formatter.rb

Constant Summary collapse

FORMAT =
"%s, [%s#%d] [%s] %5s -- %s: %s\n"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeThreadFormatter

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_formatObject

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

.layoutObject

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