Class: Lograge::Formatters::L2met
- Defined in:
- lib/lograge/formatters/l2met.rb
Constant Summary collapse
- L2MET_FIELDS =
[ :method, :path, :format, :source, :status, :error, :duration, :view, :db, :location ].freeze
Instance Method Summary collapse
- #call(data) ⇒ Object
- #fields_to_display(data) ⇒ Object
- #format(key, value) ⇒ Object
- #modify_payload(data) ⇒ Object
- #source_field(data) ⇒ Object
Instance Method Details
#call(data) ⇒ Object
19 20 21 |
# File 'lib/lograge/formatters/l2met.rb', line 19 def call(data) super(modify_payload(data)) end |
#fields_to_display(data) ⇒ Object
29 30 31 |
# File 'lib/lograge/formatters/l2met.rb', line 29 def fields_to_display(data) L2MET_FIELDS + (data.keys - L2MET_FIELDS) - [:controller, :action] end |
#format(key, value) ⇒ Object
23 24 25 26 27 |
# File 'lib/lograge/formatters/l2met.rb', line 23 def format(key, value) key = "measure#page.#{key}" if value.is_a?(Float) super(key, value) end |
#modify_payload(data) ⇒ Object
33 34 35 36 37 |
# File 'lib/lograge/formatters/l2met.rb', line 33 def modify_payload(data) data[:source] = source_field(data) if data[:controller] && data[:action] data end |
#source_field(data) ⇒ Object
39 40 41 |
# File 'lib/lograge/formatters/l2met.rb', line 39 def source_field(data) "#{data[:controller].to_s.tr('/', '-')}:#{data[:action]}" end |