Class: ExceptionNotifier::ExceptionTrackNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- ExceptionNotifier::ExceptionTrackNotifier
- Defined in:
- lib/exception_notifier/exception_track_notifier.rb
Instance Method Summary collapse
- #call(exception, _options = {}) ⇒ Object
-
#headers_for_env(env) ⇒ Object
Log Request headers from Rack env.
-
#initialize(_options) ⇒ ExceptionTrackNotifier
constructor
A new instance of ExceptionTrackNotifier.
Constructor Details
#initialize(_options) ⇒ ExceptionTrackNotifier
Returns a new instance of ExceptionTrackNotifier.
6 |
# File 'lib/exception_notifier/exception_track_notifier.rb', line 6 def initialize(); end |
Instance Method Details
#call(exception, _options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/exception_notifier/exception_track_notifier.rb', line 8 def call(exception, = {}) return unless ExceptionTrack.config.enabled_env?(Rails.env) # send the notification title = exception. || "None" = [] << headers_for_env([:env]) << "" << "--------------------------------------------------" << "" << exception.inspect unless exception.backtrace.blank? << "\n" << exception.backtrace end ExceptionTrack::Log.create(title: title[0, 200], body: .join("\n")) end |
#headers_for_env(env) ⇒ Object
Log Request headers from Rack env
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/exception_notifier/exception_track_notifier.rb', line 29 def headers_for_env(env) return "" if env.blank? parameters = env["action_dispatch.request.parameters"] || {} headers = [] headers << "Method: #{env['REQUEST_METHOD']}" headers << "URL: #{env['REQUEST_URI']}" headers << "Controller: #{parameters['controller']}##{parameters['action']}" headers << "RequestId: #{env['action_dispatch.request_id']}" headers << "User-Agent: #{env['HTTP_USER_AGENT']}" headers << "Remote IP: #{env['REMOTE_ADDR']}" headers << "Language: #{env['HTTP_ACCEPT_LANGUAGE']}" headers << "Server: #{Socket.gethostname}" headers << "Process: #{$PROCESS_ID}" headers.join("\n") end |