You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
809 B

3 months ago
3 months ago
3 months ago
  1. module Semantic
  2. class LogSubscriber < ActiveSupport::LogSubscriber
  3. include SemanticLogger::Loggable
  4. # def logger = SemanticLogger['Rails']
  5. SESSION_KEY = 'toto1'.freeze
  6. def initialize
  7. end
  8. def start_processing(event)
  9. request = event.payload[:request]
  10. rack_session = event.payload[:headers]['rack.session']
  11. session_value = rack_session.fetch(SESSION_KEY, 'EMPTY')
  12. format = event.payload[:format]
  13. format = format.to_s.upcase if format.is_a?(Symbol)
  14. format = '*/*' if format.nil?
  15. SemanticLogger.tagged(session_value) do
  16. logger.info("Started #{request.raw_request_method} #{request.filtered_path}")
  17. logger.debug("Processing by #{event.payload[:controller]}##{event.payload[:action]} as #{format}")
  18. end
  19. end
  20. end
  21. end