Class: Logging::Appenders::Airbrake
- Inherits:
-
Logging::Appender
- Object
- Logging::Appender
- Logging::Appenders::Airbrake
- Defined in:
- lib/logging/appenders/airbrake/railtie.rb,
lib/logging/appenders/airbrake.rb
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- VERSION =
"0.0.3"
- INTERNAL_BT_FILTER =
Ignore errors logged by an Airbrake sender
%r{:in\s+`send_to_airbrake'}.freeze
- AIRBRAKE_BT_FILTER =
Remove calls to this class in the stacktrace sent to Airbrake
lambda do |line| line =~ %r{/logging-[^/]+/lib/logging/} ? nil : line end
Instance Method Summary collapse
-
#initialize(*args) ⇒ Airbrake
constructor
A new instance of Airbrake.
Constructor Details
#initialize(*args) ⇒ Airbrake
Returns a new instance of Airbrake.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/logging/appenders/airbrake.rb', line 24 def initialize(*args) cfg = ::Airbrake.configuration cfg.framework = "Logging #{Logging.version}" appender = { :level => :error } args.compact! name = args.first.is_a?(String) ? args.shift : "airbrake" airbrake = args.last.is_a?(Hash) ? args.pop.dup : {} airbrake[:backtrace_filters] ||= [] airbrake[:backtrace_filters] << AIRBRAKE_BT_FILTER airbrake.keys.each do |name| unless ::Airbrake::Configuration::OPTIONS.include?(name) appender[name] = airbrake.delete(name) next end # Airbrake array attributes have no setter if cfg[name].is_a?(Array) cfg[name].concat(Array(airbrake[name])) else cfg.public_send("#{name}=", airbrake[name]) end end # We need a sender else errors will not be sent to Airbrake. # This will create a sender that may use some of the given config. ::Airbrake.configure(true) {} unless ::Airbrake.sender super(name, appender) end |