Class: LunaPark::Notifiers::Sentry

Inherits:
Object
  • Object
show all
Includes:
Extensions::Injector, Extensions::SeverityLevels
Defined in:
lib/luna_park/notifiers/sentry.rb

Constant Summary

Constants included from Extensions::SeverityLevels

Extensions::SeverityLevels::LEVELS

Instance Method Summary collapse

Methods included from Extensions::SeverityLevels

#debug, #error, #fatal, #info, #min_lvl, #min_lvl=, #unknown, #warning

Methods included from Extensions::Injector

included

Methods included from Extensions::Injector::InstanceMethods

#dependencies, #dependencies=, #inject

Methods included from Extensions::Injector::ClassMethods

#dependencies, #dependency, #inherited

Constructor Details

#initialize(min_lvl: :debug) ⇒ Sentry

Returns a new instance of Sentry.



15
16
17
# File 'lib/luna_park/notifiers/sentry.rb', line 15

def initialize(min_lvl: :debug)
  self.min_lvl = min_lvl
end

Instance Method Details

#post(msg, lvl: :error, **details) ⇒ Object

Raises:

  • (ArgumentError)


19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/luna_park/notifiers/sentry.rb', line 19

def post(msg, lvl: :error, **details)
  raise ArgumentError, "Undefined severity level `#{lvl}`" unless LEVELS.include? lvl

  message = wrap msg
  details = extend details, with: msg

  if message.is_a?(Exception)
    driver.capture_exception(message, extra: details, level: lvl)
  else
    driver.capture_message(message, extra: details, level: lvl)
  end
end