module Honeybadger
Honeybadger’s public API is made up of two parts: the {Honeybadger} singleton module, and the {Agent} class. The singleton module delegates its methods to a global agent instance, {Agent#instance}; this allows methods to be accessed directly, for example when calling Honeybadger.notify
:
begin raise 'testing an error report' rescue => err Honeybadger.notify(err) end
Custom agents may also be created by users who want to report to multiple Honeybadger
projects in the same app (or have fine-grained control over configuration), however most users will use the global agent.
@see Honeybadger::Agent
Constants
- BINDING_HAS_SOURCE_LOCATION
-
@api private Binding#source_location was added in Ruby 2.6.
- GEM_ROOT
-
@api private Substitution for gem root in backtrace lines.
- MAX_EXCEPTION_CAUSES
-
@api private
- NOTIFIER
-
@api private
- NOT_BLANK
-
@api private A Regexp which matches non-blank characters.
- PROJECT_ROOT
-
@api private Substitution for project root in backtrace lines.
- RELATIVE_ROOT
-
@api private Matches lines beginning with ./
- STRING_EMPTY
-
@api private Empty String (used for equality comparisons and assignment).
- VERSION
-
The current String
Honeybadger
version.
Public Instance Methods
Source
# File lib/honeybadger/singleton.rb, line 80 def install_at_exit_callback at_exit do if $! && !ignored_exception?($!) && Honeybadger.config[:'exceptions.notify_at_exit'] Honeybadger.notify($!, component: 'at_exit', sync: true) end Honeybadger.stop if Honeybadger.config[:'send_data_at_exit'] end end
@api private
Source
# File lib/honeybadger/singleton.rb, line 72 def load_plugins! Dir[File.expand_path('../plugins/*.rb', __FILE__)].each do |plugin| require plugin end Plugin.load!(self.config) end
@api private
Source
# File lib/honeybadger/singleton.rb, line 65 def notify(exception_or_opts=nil, opts = {}, **kwargs) # Note this is defined directly (instead of via forwardable) so that # generated stack traces work as expected. Agent.instance.notify(exception_or_opts, opts, **kwargs) end
@!method notify(…) Forwards to {Agent.instance}. @see Agent#notify
Source
# File lib/honeybadger/singleton.rb, line 91 def start(config = {}) raise NoMethodError, <<-WARNING `Honeybadger.start` is no longer necessary and has been removed. Use `Honeybadger.configure` to explicitly configure the agent from Ruby moving forward: Honeybadger.configure do |config| config.api_key = 'project api key' config.exceptions.ignore += [CustomError] end WARNING end
@deprecated
Private Instance Methods
Source
# File lib/honeybadger/singleton.rb, line 106 def ignored_exception?(exception) exception.is_a?(SystemExit) || ( exception.is_a?(SignalException) && ( (exception.respond_to?(:signm) && exception.signm == "SIGTERM") || # jruby has a missing #signm implementation ["TERM", "SIGTERM"].include?(exception.to_s) ) ) end
@api private