Class: LogStruct::MultiErrorReporter
- Inherits:
-
Object
- Object
- LogStruct::MultiErrorReporter
- Extended by:
- T::Sig
- Defined in:
- lib/log_struct/multi_error_reporter.rb
Overview
MultiErrorReporter provides a unified interface for reporting errors to various services. You can also override this with your own error reporter by setting LogStruct#.config.error_reporting_handler NOTE: This is used for cases where an error should be reported but the operation should be allowed to continue (e.g. scrubbing log data.)
Defined Under Namespace
Classes: CallableReporterWrapper
Constant Summary collapse
- ReporterImpl =
T.type_alias { T.any(ErrorReporter, CallableReporterWrapper) }
Class Method Summary collapse
-
.detect_reporter ⇒ ErrorReporter
Auto-detect which error reporting service to use.
-
.report_error(error, context = {}) ⇒ void
Report an error to the configured error reporting service.
- .reporter ⇒ ReporterImpl
-
.reporter=(reporter_type) ⇒ ReporterImpl
Set the reporter to use (user-friendly API that accepts symbols).
Class Method Details
.detect_reporter ⇒ ErrorReporter
Auto-detect which error reporting service to use
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/log_struct/multi_error_reporter.rb', line 84 def detect_reporter if defined?(::Sentry) ErrorReporter::Sentry elsif defined?(::Bugsnag) ErrorReporter::Bugsnag elsif defined?(::Rollbar) ErrorReporter::Rollbar elsif defined?(::Honeybadger) ErrorReporter::Honeybadger else ErrorReporter::RailsLogger end end |
.report_error(error, context = {}) ⇒ void
This method returns an undefined value.
Report an error to the configured error reporting service
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/log_struct/multi_error_reporter.rb', line 100 def report_error(error, context = {}) # Call the appropriate reporter method based on what's available impl = reporter_impl case impl when ErrorReporter::Sentry report_to_sentry(error, context) when ErrorReporter::Bugsnag report_to_bugsnag(error, context) when ErrorReporter::Rollbar (error, context) when ErrorReporter::Honeybadger report_to_honeybadger(error, context) when ErrorReporter::RailsLogger fallback_logging(error, context) when CallableReporterWrapper impl.call(error, context, Source::Internal) end end |
.reporter ⇒ ReporterImpl
65 66 67 |
# File 'lib/log_struct/multi_error_reporter.rb', line 65 def reporter reporter_impl end |
.reporter=(reporter_type) ⇒ ReporterImpl
Set the reporter to use (user-friendly API that accepts symbols)
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/log_struct/multi_error_reporter.rb', line 71 def reporter=(reporter_type) @reporter_impl = case reporter_type when ErrorReporter reporter_type when Symbol resolve_symbol_reporter(reporter_type) else wrap_callable_reporter(reporter_type) end end |