Sha256: bd0e36651551d932551d4501cec9b9266c82b7004a712b8fe869bc06633de97c
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
# frozen_string_literal: true # 异常通知 module ExceptionNotifier class ExceptionTrackNotifier < ExceptionNotifier::BaseNotifier def initialize(_options); end def call(exception, _options = {}) return unless ExceptionTrack.config.enabled_env?(Rails.env) # send the notification @title = exception.message messages = [] messages << headers_for_env(_options[:env]) messages << "" messages << "--------------------------------------------------" messages << "" messages << exception.inspect unless exception.backtrace.blank? messages << "\n" messages << exception.backtrace end ExceptionTrack::Log.create(title: @title, body: messages.join("\n")) end # Log Request headers from Rack env 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
exception-track-0.3.1 | lib/exception_notifier/exception_track_notifier.rb |