Class: Lograge::RequestLogSubscriber

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

Instance Method Summary collapse

Instance Method Details

#loggerObject



29
30
31
# File 'lib/lograge/log_subscriber.rb', line 29

def logger
  Lograge.logger.presence || super
end

#process_action(event) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/lograge/log_subscriber.rb', line 8

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

  payload = event.payload

  data      = extract_time(event)
  data.merge! extract_request(payload)
  data.merge! extract_status(payload)
  data.merge! runtimes(event)
  data.merge! location(event)
  data.merge! custom_options(event)

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

#redirect_to(event) ⇒ Object



25
26
27
# File 'lib/lograge/log_subscriber.rb', line 25

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