Module: MrLogaLoga::Extensions::LogrageExtension
- Defined in:
- lib/mr_loga_loga/extensions/lograge.rb
Overview
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
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.apply ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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 |
Instance Method Details
#process_main_event(event) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# 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 = Lograge.formatter.call(data) logger.send(Lograge.log_level, ) end end |