Class: HubriseInitializer::Lograge

Inherits:
Object
  • Object
show all
Defined in:
lib/hubrise_initializer/lograge.rb

Class Method Summary collapse

Class Method Details

.custom_options(_event) ⇒ Object



7
8
9
# File 'lib/hubrise_initializer/lograge.rb', line 7

def custom_options(_event)
  {}
end

.custom_payload(controller) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hubrise_initializer/lograge.rb', line 11

def custom_payload(controller)
  request = controller.request
  response = controller.response
  extra = controller.request.env[HubriseInitializer::LOGRAGE_INFO_ENV] || {}

  {
    release: ENV["RELEASE"],
    host: request.host,
    ip: request.ip,
    params: request.query_string.presence,
  }.merge(extra)
    .merge(
      if ENV["RAILS_LOGRAGE_QUERY"] == "true"
        {
          request_headers: process_request_headers(request).to_s,
          request_body: truncate_body(switch_to_utf8(request.raw_post)),
          response_headers: response.headers.to_h.to_s,
          response_body: truncate_body(switch_to_utf8(response.body)),
        }
      else
        {}
      end
    )
end