Class: Lograge::RequestLogSubscriber

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

Instance Method Summary collapse

Instance Method Details

#loggerObject



27
28
29
# File 'lib/lograge/log_subscriber.rb', line 27

def logger
  Lograge.logger.presence || super
end

#process_action(event) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/lograge/log_subscriber.rb', line 8

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

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

#redirect_to(event) ⇒ Object



18
19
20
# File 'lib/lograge/log_subscriber.rb', line 18

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

#unpermitted_parameters(event) ⇒ Object



22
23
24
25
# File 'lib/lograge/log_subscriber.rb', line 22

def unpermitted_parameters(event)
  Thread.current[:lograge_unpermitted_params] ||= []
  Thread.current[:lograge_unpermitted_params].concat(event.payload[:keys])
end