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.



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

def initialize
    @datetime_format = nil
end

Instance Attribute Details

#datetime_formatObject

Returns the value of attribute datetime_format.



86
87
88
# File 'lib/ocular/logging/console_logger.rb', line 86

def datetime_format
  @datetime_format
end

Instance Method Details

#format_cause(type, environment, time) ⇒ Object



100
101
102
# File 'lib/ocular/logging/console_logger.rb', line 100

def format_cause(type, environment, time)
    CauseFormat % [format_datetime(time), $$, type, environment.to_json]
end

#format_event(property, value, time) ⇒ Object



96
97
98
# File 'lib/ocular/logging/console_logger.rb', line 96

def format_event(property, value, time)
    EventFormat % [format_datetime(time), $$, property, value]
end

#format_message(severity, time, msg) ⇒ Object



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

def format_message(severity, time, msg)
    Format % [format_datetime(time), $$, Ocular::Logging::Severity::LABELS[severity], msg2str(msg)]
end

#format_timing(key, value, time) ⇒ Object



104
105
106
# File 'lib/ocular/logging/console_logger.rb', line 104

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