Class: Lumberjack::Template::StandardFormatterTemplate
- Inherits:
-
Lumberjack::Template
- Object
- Lumberjack::Template
- Lumberjack::Template::StandardFormatterTemplate
- Defined in:
- lib/lumberjack/template.rb
Overview
A wrapper template that delegates formatting to a standard Ruby Logger formatter. This provides compatibility with existing Logger::Formatter implementations while maintaining the Template interface for consistent usage within Lumberjack.
Constant Summary
Constants inherited from Lumberjack::Template
DEFAULT_ADDITIONAL_LINES_TEMPLATE, DEFAULT_ATTRIBUTE_FORMAT, DEFAULT_FIRST_LINE_TEMPLATE, STDLIB_FIRST_LINE_TEMPLATE
Instance Method Summary collapse
-
#call(entry) ⇒ String
Format a log entry using the wrapped formatter.
-
#datetime_format ⇒ String?
Get the datetime format from the wrapped formatter if supported.
-
#datetime_format=(value) ⇒ void
Set the datetime format on the wrapped formatter if supported.
-
#initialize(formatter) ⇒ StandardFormatterTemplate
constructor
Create a new wrapper for a standard Ruby Logger formatter.
Methods inherited from Lumberjack::Template
Constructor Details
#initialize(formatter) ⇒ StandardFormatterTemplate
Create a new wrapper for a standard Ruby Logger formatter.
60 61 62 |
# File 'lib/lumberjack/template.rb', line 60 def initialize(formatter) @formatter = formatter end |
Instance Method Details
#call(entry) ⇒ String
Format a log entry using the wrapped formatter.
68 69 70 |
# File 'lib/lumberjack/template.rb', line 68 def call(entry) @formatter.call(entry.severity_label, entry.time, entry.progname, entry.) end |
#datetime_format ⇒ String?
Get the datetime format from the wrapped formatter if supported.
83 84 85 |
# File 'lib/lumberjack/template.rb', line 83 def datetime_format @formatter.datetime_format if @formatter.respond_to?(:datetime_format) end |
#datetime_format=(value) ⇒ void
This method returns an undefined value.
Set the datetime format on the wrapped formatter if supported.
76 77 78 |
# File 'lib/lumberjack/template.rb', line 76 def datetime_format=(value) @formatter.datetime_format = value if @formatter.respond_to?(:datetime_format=) end |