Module: ActiveSupport::TaggedLogging::FormatterExtension
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/log_struct/monkey_patches/active_support/tagged_logging/formatter.rb
Instance Method Summary collapse
-
#call(severity, time, progname, data) ⇒ String
Override the call method to support hash input/output, and wrap plain strings in a Hash under a
msg
key.
Instance Method Details
#call(severity, time, progname, data) ⇒ String
Override the call method to support hash input/output, and wrap
plain strings in a Hash under a msg
key.
The data is then passed to our custom log formatter that transforms it
into a JSON string before logging.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/log_struct/monkey_patches/active_support/tagged_logging/formatter.rb', line 21 def call(severity, time, progname, data) # Convert data to a hash if it's not already one data = {message: data.to_s} unless data.is_a?(Hash) # Add current tags to the hash if present = data[:tags] = if .present? # Call the original formatter with our enhanced data super end |