Class: LunaPark::Notifiers::Bugsnag

Inherits:
Object
  • Object
show all
Includes:
Extensions::SeverityLevels
Defined in:
lib/luna_park/notifiers/bugsnag.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

Constructor Details

#initialize(min_lvl: :debug) ⇒ Bugsnag

Returns a new instance of Bugsnag.



11
12
13
# File 'lib/luna_park/notifiers/bugsnag.rb', line 11

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

Instance Method Details

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

rubocop:disable Metrics/MethodLength

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/luna_park/notifiers/bugsnag.rb', line 15

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

  message = wrap msg
  details = extend details, with: msg
  ::Bugsnag.notify(message) do |report|
    report.add_tab(:details, details)

    if %i[fatal unknown].include? lvl
      report.add_tab(:original_message_severity, lvl)
      report.severity = :error
    else
      report.severity = lvl
    end
  end
end