Class: Onelinejson::TestSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/onelinejson.rb

Instance Method Summary collapse

Instance Method Details

#loggerObject



34
35
36
# File 'lib/onelinejson.rb', line 34

def logger
  ::Lograge.logger.presence or super
end

#process_action(event) ⇒ Object



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

def process_action(event)
  return if ::Lograge.ignore?(event)

  data = {
    request: {},
    response: {},
    debug_info: {}
  }
  payload = event.payload

  data[:request].merge! extract_request(payload)
  data[:response].merge! extract_status(payload)
  data[:response].merge! runtimes(event)
  data[:response].merge! location(event)
  data.merge! custom_options(event)

  formatted_message = ::Lograge.formatter.call(data)
  logger.send(::Lograge.log_level, formatted_message)
end

#redirect_to(event) ⇒ Object



30
31
32
# File 'lib/onelinejson.rb', line 30

def redirect_to(event)
  Thread.current[:lograge_location] = event.payload[:location]
end