Class: Logger::Formatter

Inherits:
Object show all
Defined in:
opal/stdlib/logger.rb

Constant Summary collapse

MESSAGE_FORMAT =
"%s, [%s] %5s -- %s: %s\n"
DATE_TIME_FORMAT =
'%Y-%m-%dT%H:%M:%S.%6N'

Instance Method Summary collapse

Instance Method Details

#call(severity, time, progname, msg) ⇒ Object



20
21
22
# File 'opal/stdlib/logger.rb', line 20

def call(severity, time, progname, msg)
  format(MESSAGE_FORMAT, severity.chr, time.strftime(DATE_TIME_FORMAT), severity, progname, message_as_string(msg))
end

#message_as_string(msg) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'opal/stdlib/logger.rb', line 24

def message_as_string(msg)
  case msg
  when ::String
    msg
  when ::Exception
    msg.full_message
  else
    msg.inspect
  end
end