Class: ExceptionNotifier::YamlNotifier
- Inherits:
-
Object
- Object
- ExceptionNotifier::YamlNotifier
- Defined in:
- lib/exception_notifier/yaml_notifier.rb
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
-
#initialize(options) ⇒ YamlNotifier
constructor
A new instance of YamlNotifier.
Constructor Details
#initialize(options) ⇒ YamlNotifier
Returns a new instance of YamlNotifier.
6 7 8 9 |
# File 'lib/exception_notifier/yaml_notifier.rb', line 6 def initialize() # initialize options here @extra_params = [:extra_params] || [] end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/exception_notifier/yaml_notifier.rb', line 11 def call(exception, ={}) log = ::YamlNotifier::ExceptionLog.new({ title: exception.inspect, message: exception., backtrace: exception.backtrace.join("\n") }) env = [:env] unless env.nil? log.user_agent = env['HTTP_USER_AGENT'] log.request_uri = env['REQUEST_URI'] log.request_method = env['REQUEST_METHOD'] log.controller = env['action_dispatch.request.path_parameters'][:controller] log.action = env['action_dispatch.request.path_parameters'][:action] log.extra_params = @extra_params.map{|p| env[p]} unless @extra_params.empty? end log.save end |