Class: Sapience::ErrorHandler::Sentry
- Inherits:
-
Sapience::ErrorHandler
- Object
- Sapience::ErrorHandler
- Sapience::ErrorHandler::Sentry
- Defined in:
- lib/sapience/error_handler/sentry.rb
Constant Summary collapse
- VALIDATION_MESSAGE =
"DSN is not valid, please add appender with :dsn key or set SENTRY_DSN".freeze
- URI_REGEXP =
URI::DEFAULT_PARSER.regexp[:ABS_URI]
Instance Method Summary collapse
- #capture_exception(exception, payload = {}) ⇒ Object
- #capture_message(message, payload = {}) ⇒ Object
- #configure_sentry ⇒ Object
- #configured? ⇒ Boolean
-
#initialize(options = {}) ⇒ Sentry
constructor
level: [:trace | :debug | :info | :warn | :error | :fatal] Override the log level for this appender.
- #valid? ⇒ Boolean
Methods included from Descendants
Constructor Details
#initialize(options = {}) ⇒ Sentry
level: [:trace | :debug | :info | :warn | :error | :fatal]
Override the log level for this appender.
Default: Sapience.config.default_level
dsn: [String]
Url to configure Sentry-Raven.
Default: nil
26 27 28 29 30 31 32 33 |
# File 'lib/sapience/error_handler/sentry.rb', line 26 def initialize( = {}) fail ArgumentError, "Options should be a Hash" unless .is_a?(Hash) [:level] ||= :error @sentry_logger_level = [:level] @sentry_dsn = .delete(:dsn) @configured = false end |
Instance Method Details
#capture_exception(exception, payload = {}) ⇒ Object
39 40 41 |
# File 'lib/sapience/error_handler/sentry.rb', line 39 def capture_exception(exception, payload = {}) capture(exception, payload) end |
#capture_message(message, payload = {}) ⇒ Object
43 44 45 |
# File 'lib/sapience/error_handler/sentry.rb', line 43 def (, payload = {}) capture(, payload) end |
#configure_sentry ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/sapience/error_handler/sentry.rb', line 51 def configure_sentry return if configured? Raven.configure do |config| config.server = sentry_dsn config. = { environment: Sapience.environment } config.logger = sentry_logger end @configured = true end |
#configured? ⇒ Boolean
47 48 49 |
# File 'lib/sapience/error_handler/sentry.rb', line 47 def configured? @configured == true end |
#valid? ⇒ Boolean
35 36 37 |
# File 'lib/sapience/error_handler/sentry.rb', line 35 def valid? sentry_dsn =~ URI_REGEXP end |