class Ocular::Logging::ConsoleLogger::Formatter
Default formatter for log messages.
Constants
- CauseFormat
- EventFormat
- Format
- TimingFormat
Attributes
datetime_format[RW]
Public Class Methods
new()
click to toggle source
# File lib/ocular/logging/console_logger.rb, line 91 def initialize @datetime_format = nil end
Public Instance Methods
format_cause(type, environment, time)
click to toggle source
# File lib/ocular/logging/console_logger.rb, line 103 def format_cause(type, environment, time) CauseFormat % [format_datetime(time), $$, type, environment.to_json] end
format_event(property, value, time)
click to toggle source
# File lib/ocular/logging/console_logger.rb, line 99 def format_event(property, value, time) EventFormat % [format_datetime(time), $$, property, value] end
format_message(severity, time, msg)
click to toggle source
# File lib/ocular/logging/console_logger.rb, line 95 def format_message(severity, time, msg) Format % [format_datetime(time), $$, Ocular::Logging::Severity::LABELS[severity], msg2str(msg)] end
format_timing(key, value, time)
click to toggle source
# File lib/ocular/logging/console_logger.rb, line 107 def format_timing(key, value, time) TimingFormat % [format_datetime(time), $$, key, value] end
Private Instance Methods
format_datetime(time)
click to toggle source
# File lib/ocular/logging/console_logger.rb, line 113 def format_datetime(time) time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ".freeze) end
msg2str(msg)
click to toggle source
# File lib/ocular/logging/console_logger.rb, line 117 def msg2str(msg) case msg when ::String msg when ::Exception "#{ msg.message } (#{ msg.class })\n" << (msg.backtrace || []).join("\n") else msg.inspect end end