Module: LogFormatter::Common

Included in:
Log4r::JSONFormatter::Base, Ruby::JSONFormatter::Base, Ruby::TextFormatter::Base
Defined in:
lib/log_formatter/common.rb

Defined Under Namespace

Modules: JSON, Text

Instance Method Summary collapse

Instance Method Details

#current_time(time) ⇒ Object



14
15
16
17
# File 'lib/log_formatter/common.rb', line 14

def current_time(time)
  return time if time
  Time.respond_to?(:current) ? Time.current : Time.now
end

#msg2str(msg) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/log_formatter/common.rb', line 2

def msg2str(msg)
  case msg
  when ::String
    msg.gsub("\n", "\t")
  when ::Exception
    "#{ msg.message } (#{ msg.class })\t" <<
      (msg.backtrace || []).join("\t")
  else
    msg.inspect
  end
end