Class: Ezlog::LoggingLayout
- Inherits:
-
Logging::Layout
- Object
- Logging::Layout
- Ezlog::LoggingLayout
- Defined in:
- lib/ezlog/logging_layout.rb
Instance Method Summary collapse
- #format(event) ⇒ Object
-
#initialize(context = {}, options = {}) ⇒ LoggingLayout
constructor
A new instance of LoggingLayout.
Constructor Details
#initialize(context = {}, options = {}) ⇒ LoggingLayout
Returns a new instance of LoggingLayout.
6 7 8 9 |
# File 'lib/ezlog/logging_layout.rb', line 6 def initialize(context = {}, = {}) @initial_context = context @level_formatter = .fetch(:level_formatter, ->(numeric_level) { ::Logging::LNAMES[numeric_level] }) end |
Instance Method Details
#format(event) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/ezlog/logging_layout.rb', line 11 def format(event) log_entry = basic_information_for event add_initial_context_to log_entry add_logging_context_to log_entry add_event_information_to log_entry, event ::Oj.dump(log_entry, mode: :json) + "\n" end |