class DebugLogging::LogSubscriber

Constants

EVENT_FORMAT_STRING
EXCLUDE_FROM_PAYLOAD

Attributes

event[RW]

Public Class Methods

event_to_format_options(event) click to toggle source

@param [ActiveSupport::Notifications::Event] @return [Hash]

# File lib/debug_logging/log_subscriber.rb, line 29
def self.event_to_format_options(event)
  args = event.payload[:debug_args]
  config_proxy = event.payload[:config_proxy]
  payload = event.payload.reject { |k, _| EXCLUDE_FROM_PAYLOAD.include?(k) }
  {
    name: event.name,
    duration: Rational(event.duration, 1000).to_f,
    time: event.time,
    end: event.end,
    args: debug_signature_to_s(args: args, config_proxy: config_proxy),
    payload: debug_payload_to_s(payload: payload, config_proxy: config_proxy)
  }
end
log_event(event) click to toggle source
# File lib/debug_logging/log_subscriber.rb, line 17
def self.log_event(event)
  @event = event
  if event.payload && event.payload[:exception_object]
    exception = event.payload[:exception_object]
    "#{event.name} [ERROR] : \n#{exception.class} : #{exception.message}\n" + exception.backtrace.join("\n")
  else
    format(EVENT_FORMAT_STRING, event_to_format_options(event))
  end
end