Class: Logging::Formatters::Default
- Inherits:
-
Object
- Object
- Logging::Formatters::Default
- Defined in:
- lib/logging/formatters.rb
Overview
Default formatter. No colours, just log level, time stamp, label and the actual log message.
Direct Known Subclasses
Constant Summary collapse
- FORMAT_STRINGS =
Format strings.
The ‘single` key is used by #format_single_message, whereas `header` is used by #format_multiple_messages.
{ single: '%-5s %s -- %s', header: '%-5s %s' }
Instance Method Summary collapse
-
#format_multiple_messages(level, label, messages, &block) ⇒ String
Format multiple log messages.
-
#format_single_message(level, label, message, &block) ⇒ String
Format single log message.
Instance Method Details
#format_multiple_messages(level, label, messages, &block) ⇒ String
TODO:
There’s no documentation for the block yet, it’s being used only for extending functionality from the subclasses. It should be probably refactored, otherwise it will get proper documentation.
Format multiple log messages.
61 62 63 64 65 66 67 68 |
# File 'lib/logging/formatters.rb', line 61 def (level, label, , &block) args = [level.to_s.upcase, ] args = block.call(*args) if block header = sprintf(self.class::FORMAT_STRINGS[:header], *args) .unshift(nil) header + .join("\n ") end |
#format_single_message(level, label, message, &block) ⇒ String
TODO:
There’s no documentation for the block yet, it’s being used only for extending functionality from the subclasses. It should be probably refactored, otherwise it will get proper documentation.
Format single log message.
38 39 40 41 42 |
# File 'lib/logging/formatters.rb', line 38 def (level, label, , &block) args = [label, , ] args = block.call(*args) if block sprintf(self.class::FORMAT_STRINGS[:single], *args) end |