Class: Logcraft::LogLayout
- Inherits:
-
Logging::Layout
- Object
- Logging::Layout
- Logcraft::LogLayout
- Defined in:
- lib/logcraft/log_layout.rb
Constant Summary collapse
- JSON_FORMATTER =
->(event) { MultiJson.dump(event) + "\n" }.freeze
- LOGGING_LEVEL_FORMATTER =
->(level) { Logging::LNAMES[level] }.freeze
Instance Method Summary collapse
- #format(event) ⇒ Object
-
#initialize(global_context = {}, options = {}) ⇒ LogLayout
constructor
A new instance of LogLayout.
Constructor Details
#initialize(global_context = {}, options = {}) ⇒ LogLayout
Returns a new instance of LogLayout.
10 11 12 13 14 |
# File 'lib/logcraft/log_layout.rb', line 10 def initialize(global_context = {}, = {}) @global_context = global_context @formatter = .fetch :formatter, JSON_FORMATTER @level_formatter = .fetch :level_formatter, LOGGING_LEVEL_FORMATTER end |
Instance Method Details
#format(event) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/logcraft/log_layout.rb', line 16 def format(event) log_entry = background_of(event).merge evaluated_global_context, dynamic_log_context, (event.data) @formatter.call log_entry end |