Class: Ocular::Logging::ConsoleLogger::Formatter
- Inherits:
-
Object
- Object
- Ocular::Logging::ConsoleLogger::Formatter
- 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
-
#datetime_format ⇒ Object
Returns the value of attribute datetime_format.
Instance Method Summary collapse
- #format_cause(type, environment, time) ⇒ Object
- #format_event(property, value, time) ⇒ Object
- #format_message(severity, time, msg) ⇒ Object
- #format_timing(key, value, time) ⇒ Object
-
#initialize ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize ⇒ Formatter
Returns a new instance of Formatter.
57 58 59 |
# File 'lib/ocular/logging/console_logger.rb', line 57 def initialize @datetime_format = nil end |
Instance Attribute Details
#datetime_format ⇒ Object
Returns the value of attribute datetime_format.
55 56 57 |
# File 'lib/ocular/logging/console_logger.rb', line 55 def datetime_format @datetime_format end |
Instance Method Details
#format_cause(type, environment, time) ⇒ Object
69 70 71 |
# File 'lib/ocular/logging/console_logger.rb', line 69 def format_cause(type, environment, time) CauseFormat % [format_datetime(time), $$, type, environment.to_json] end |
#format_event(property, value, time) ⇒ Object
65 66 67 |
# File 'lib/ocular/logging/console_logger.rb', line 65 def format_event(property, value, time) EventFormat % [format_datetime(time), $$, property, value] end |
#format_message(severity, time, msg) ⇒ Object
61 62 63 |
# File 'lib/ocular/logging/console_logger.rb', line 61 def (severity, time, msg) Format % [format_datetime(time), $$, Ocular::Logging::Severity::LABELS[severity], msg2str(msg)] end |
#format_timing(key, value, time) ⇒ Object
73 74 75 |
# File 'lib/ocular/logging/console_logger.rb', line 73 def format_timing(key, value, time) TimingFormat % [format_datetime(time), $$, key, value] end |