class Sqreen::FormatterWithTid

Ruby default formatter modified to display current thread_id

Constants

DatetimeFormat
Format

TODO: constant name

Attributes

datetime_format[RW]

Public Class Methods

new() click to toggle source
# File lib/sqreen/formatter_with_tid.rb, line 17
def initialize
  @datetime_format = nil
end

Public Instance Methods

call(severity, time, progname, msg) click to toggle source
# File lib/sqreen/formatter_with_tid.rb, line 21
def call(severity, time, progname, msg)
  format(
    Format,
    severity[0..0], format_datetime(time), $$,
    Thread.current.object_id.to_s(36),
    severity, progname, msg2str(msg),
  )
end

Private Instance Methods

format_datetime(time) click to toggle source
# File lib/sqreen/formatter_with_tid.rb, line 32
def format_datetime(time)
  time.strftime(DatetimeFormat)
end
msg2str(msg) click to toggle source
# File lib/sqreen/formatter_with_tid.rb, line 36
def msg2str(msg)
  case msg
  when ::String
    msg
  when ::Exception
    "#{msg.message} (#{msg.class})\n" << (msg.backtrace || []).join("\n")
  else
    msg.inspect
  end
end