Class: UmbrellioUtils::SemanticLogger::TinyJsonFormatter
- Inherits:
-
Object
- Object
- UmbrellioUtils::SemanticLogger::TinyJsonFormatter
- Defined in:
- lib/umbrellio_utils/semantic_logger/tiny_json_formatter.rb
Overview
Simple JSON formatter, represented as callable object.
Constant Summary collapse
- DEFAULT_NAMES_MAPPING =
Hash with default field names in the output JSON.
{ severity: :severity, name: :name, thread_fingerprint: :thread_fingerprint, message: :message, tags: :tags, named_tags: :named_tags, time: :time, }.freeze
Instance Method Summary collapse
-
#call(log, _logger) ⇒ String
Formats log structure into the JSON string.
-
#initialize(message_size_limit: 10_000, custom_names_mapping: {}) ⇒ UmbrellioUtils::SemanticLogger::TinyJsonFormatter
constructor
Returns a new instance of the TinyJsonFormatter.
Constructor Details
#initialize(message_size_limit: 10_000, custom_names_mapping: {}) ⇒ UmbrellioUtils::SemanticLogger::TinyJsonFormatter
Returns a new instance of the UmbrellioUtils::SemanticLogger::TinyJsonFormatter.
40 41 42 43 |
# File 'lib/umbrellio_utils/semantic_logger/tiny_json_formatter.rb', line 40 def initialize(message_size_limit: 10_000, custom_names_mapping: {}) self. = self.field_names = { **DEFAULT_NAMES_MAPPING, **custom_names_mapping }.freeze end |
Instance Method Details
#call(log, _logger) ⇒ String
Formats log structure into the JSON string.
49 50 51 52 |
# File 'lib/umbrellio_utils/semantic_logger/tiny_json_formatter.rb', line 49 def call(log, _logger) data = build_data_for(log) data.to_json end |