Class: Ocular::Logging::ConsoleLogger::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/ocular/logging/console_logger.rb

Overview

Default formatter for log messages.

Constant Summary collapse

Format =
"[%s#%d] %s -- %s\n".freeze
EventFormat =
"[%s#%d] -- %s: %s\n".freeze
CauseFormat =
"[%s#%d] -- %s triggered processing with environment: %s\n".freeze
TimingFormat =
"[%s#%d] -- %s took %s ms\n".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFormatter

Returns a new instance of Formatter.



91
92
93
# File 'lib/ocular/logging/console_logger.rb', line 91

def initialize
    @datetime_format = nil
end

Instance Attribute Details

#datetime_formatObject

Returns the value of attribute datetime_format.



89
90
91
# File 'lib/ocular/logging/console_logger.rb', line 89

def datetime_format
  @datetime_format
end

Instance Method Details

#format_cause(type, environment, time) ⇒ Object



103
104
105
# 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) ⇒ Object



99
100
101
# 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) ⇒ Object



95
96
97
# 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) ⇒ Object



107
108
109
# File 'lib/ocular/logging/console_logger.rb', line 107

def format_timing(key, value, time)
    TimingFormat % [format_datetime(time), $$, key, value]
end