Module: NdrError::Logging
- Included in:
- NdrError
- Defined in:
- lib/ndr_error/logging.rb
Overview
Module to contain helpers for logging
Constant Summary collapse
- ANCILLARY_ATTRS_WHITELIST =
Which attributes can be populated when manually logging an exception:
i[user_id user_roles svn_revision].freeze
Instance Method Summary collapse
-
#log(exception, ancillary_data, request_object) ⇒ Object
Log the given ‘exception`.
- #monitor(ancillary_data: {}, request: nil, swallow: false) ⇒ Object
Instance Method Details
#log(exception, ancillary_data, request_object) ⇒ Object
Log the given ‘exception`.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ndr_error/logging.rb', line 8 def log(exception, ancillary_data, request_object) # Capture details about a parent exception, if possible: parent_print, = exception.cause && log(exception.cause, ancillary_data, request_object) log = initialize_log(ancillary_data) log.register_exception(exception) log.register_request(request_object) log.register_parent(parent_print) print = Fingerprint.find_or_create_by_id(log.md5_digest) print.causal_error_fingerprint = parent_print log = print.store_log(log) NdrError.run_after_log_callbacks(exception, print, log) [print, log] end |
#monitor(ancillary_data: {}, request: nil, swallow: false) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/ndr_error/logging.rb', line 26 def monitor(ancillary_data: {}, request: nil, swallow: false) yield rescue Exception => exception # rubocop:disable Lint/RescueException data = log(exception, ancillary_data, request) swallow ? data : raise(exception) end |