Module: RailsCustomLogging::Transformers::Default

Defined in:
lib/rails_custom_logging/transformers/default.rb

Overview

Transforms a ActiveSupport::Notifications::Event into a Hash with basic values any application could use.

Class Method Summary collapse

Class Method Details

.call(event) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rails_custom_logging/transformers/default.rb', line 10

def call(event)
  payload = event.payload.dup

  if payload.key?(:params)
    payload[:params] = payload[:params].except('action', 'controller', 'id')
    payload.delete(:params) if payload[:params].empty?
  end

  payload[:duration] = event.duration
  payload[:allocations] = event.allocations

  payload.delete(:headers)
  payload.delete(:response)
  payload[:path] = extract_path(payload)
  payload.delete(:request)

  payload
end