Module: Lumberjack::Rails::TaggedLoggingFormatter

Defined in:
lib/lumberjack/rails/tagged_logging_formatter.rb

Overview

Extension for the Lumberjack::EntryFormatter that adds support for adding the array of tags added by ActiveSupport::TaggedLogging.

This module integrates ActiveSupport’s tagged logging mechanism with Lumberjack’s entry formatting, ensuring that tags from Rails’ tagged logging are properly included in the formatted log output.

Instance Method Summary collapse

Instance Method Details

#format(message, tags) ⇒ String

Format a log message with support for ActiveSupport tagged logging.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lumberjack/rails/tagged_logging_formatter.rb', line 16

def format(message, tags)
  tagged_values = current_tags if respond_to?(:current_tags)
  if tagged_values && !tagged_values.empty?
    tagged = {"tags" => tagged_values}
    new_tags = tags.nil? ? tagged : tags.merge(tagged)
  else
    new_tags = tags
  end

  super(message, new_tags)
end