module MrLogaLoga::Extensions::LogrageExtension
Description¶ ↑
This patches Lograge to forward data as context to MrLogaLoga
.
We want Lograge to forward requeest data not to it’s own formatter and then to the logger, as this would make that data part of the message. Rather, where Lograge normally sends the formatted message to the logger we send the raw data.
This effectively circumvents Lograge’s formatters.
Patches¶ ↑
-
Lograge::LogSubscribers#process_main_event
Public Class Methods
apply()
click to toggle source
# File lib/mr_loga_loga/extensions/lograge.rb, line 21 def apply return unless defined?(Lograge) patch_applies = defined?(Lograge::LogSubscribers::Base) && Lograge::LogSubscribers::Base.private_method_defined?(:process_main_event) unless patch_applies puts "WARNING: Failed to patch Lograge. It looks like MrLogaLoga's patch no longer applies in "\ "#{__FILE__}. Please contact MrLogaLoga maintainers." return end Lograge::LogSubscribers::Base.prepend(self) end
Public Instance Methods
process_main_event(event)
click to toggle source
# File lib/mr_loga_loga/extensions/lograge.rb, line 36 def process_main_event(event) return if Lograge.ignore?(event) payload = event.payload data = extract_request(event, payload) data = before_format(data, payload) # Instead of if logger.is_a?(MrLogaLoga::Logger) logger.send(Lograge.log_level, '', **data) else formatted_message = Lograge.formatter.call(data) logger.send(Lograge.log_level, formatted_message) end end