Sha256: 2fe7f3ee16032080d868a107cc244f97a536f6b79dbdf168457670f03aa74f0e
Contents?: true
Size: 1.54 KB
Versions: 36
Compression:
Stored size: 1.54 KB
Contents
require 'sinatra/base' require 'honeybadger/ruby' module Honeybadger module Init module Sinatra ::Sinatra::Base.class_eval do class << self def build_with_honeybadger(*args, &block) configure_honeybadger install_honeybadger # Sinatra is a special case. Sinatra starts the web application in an at_exit # handler. And, since we require sinatra before requiring HB, the only way to # setup our at_exit callback is in the sinatra build callback honeybadger/init/sinatra.rb Honeybadger.install_at_exit_callback build_without_honeybadger(*args, &block) end alias :build_without_honeybadger :build alias :build :build_with_honeybadger def configure_honeybadger return unless defined?(honeybadger_api_key) Honeybadger.configure do |config| config.api_key = honeybadger_api_key end end def install_honeybadger config = Honeybadger.config return unless config[:'sinatra.enabled'] install_honeybadger_middleware(Honeybadger::Rack::ErrorNotifier) if config[:'exceptions.enabled'] end def install_honeybadger_middleware(klass) return if middleware.any? {|m| m[0] == klass } use(klass) end end end end end end Honeybadger.init!({ env: ENV['APP_ENV'] || ENV['RACK_ENV'], framework: :sinatra, :'logging.path' => 'STDOUT' }) Honeybadger.load_plugins!
Version data entries
36 entries across 36 versions & 1 rubygems