Class: BetterLogFormatter
- Inherits:
-
Logger::Formatter
- Object
- Logger::Formatter
- BetterLogFormatter
- Defined in:
- lib/better_log_formatter.rb
Constant Summary collapse
- VERSION =
"0.1.0".freeze
- Format =
"%s%s[%d]%s%s -- %s: %s\n".freeze
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#datetime_display ⇒ Object
Returns the value of attribute datetime_display.
Instance Method Summary collapse
- #call(severity, datetime, _, message) ⇒ Object
- #custom_tag(tag_name, &block) ⇒ Object
-
#initialize(app_name) ⇒ BetterLogFormatter
constructor
A new instance of BetterLogFormatter.
Constructor Details
#initialize(app_name) ⇒ BetterLogFormatter
Returns a new instance of BetterLogFormatter.
10 11 12 13 14 |
# File 'lib/better_log_formatter.rb', line 10 def initialize(app_name) @app_name = app_name @datetime = datetime_display super() end |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
7 8 9 |
# File 'lib/better_log_formatter.rb', line 7 def app_name @app_name end |
#datetime_display ⇒ Object
Returns the value of attribute datetime_display.
8 9 10 |
# File 'lib/better_log_formatter.rb', line 8 def datetime_display @datetime_display end |
Instance Method Details
#call(severity, datetime, _, message) ⇒ Object
16 17 18 |
# File 'lib/better_log_formatter.rb', line 16 def call(severity, datetime, _, ) Format % [formatted_datetime(datetime), app_name, $$, , , severity_label(severity), msg2str()] end |
#custom_tag(tag_name, &block) ⇒ Object
20 21 22 23 24 |
# File 'lib/better_log_formatter.rb', line 20 def custom_tag(tag_name, &block) @custom_tags ||= {} @custom_tags[tag_name] = block true end |