lib/honeybadger/config.rb in honeybadger-2.0.12 vs lib/honeybadger/config.rb in honeybadger-2.1.0.beta.1
- old
+ new
@@ -8,10 +8,11 @@
require 'honeybadger/logging'
require 'honeybadger/backend'
require 'honeybadger/config/defaults'
require 'honeybadger/util/http'
require 'honeybadger/logging'
+require 'honeybadger/rack/request_hash'
module Honeybadger
class Config
extend Forwardable
@@ -23,12 +24,10 @@
autoload :Env, 'honeybadger/config/env'
autoload :Yaml, 'honeybadger/config/yaml'
KEY_REPLACEMENT = Regexp.new('[^a-z\d_]', Regexp::IGNORECASE).freeze
- DISALLOWED_KEYS = [:'config.path'].freeze
-
DOTTED_KEY = Regexp.new('\A([^\.]+)\.(.+)\z').freeze
NOT_BLANK = Regexp.new('\S').freeze
FEATURES = [:notices, :local_variables, :metrics, :traces].freeze
@@ -37,10 +36,12 @@
OVERRIDE = {
:'exceptions.ignore' => :'exceptions.ignore_only'
}.freeze
+ DEFAULT_REQUEST_HASH = {}.freeze
+
def initialize(opts = {})
l = opts.delete(:logger)
@values = opts
@@ -134,20 +135,20 @@
if self[:'logging.path'] && self[:'logging.path'] != 'STDOUT'
locate_absolute_path(self[:'logging.path'], self[:root])
end
end
- # Internal: Path to honeybadger.yml configuration file; this should be the root
- # directory if no path was specified.
+ # Internal: Path to honeybadger.yml configuration file; this should be the
+ # root directory if no path was specified.
#
# Returns the Pathname configuration path.
def config_path
- locate_absolute_path(Array(self[:'config.path']).first, self[:root])
+ config_paths.first
end
def config_paths
- Array(self[:'config.path']).map do |c|
+ Array(ENV['HONEYBADGER_CONFIG_PATH'] || get(:'config.path')).map do |c|
locate_absolute_path(c, self[:root])
end
end
def ca_bundle_path
@@ -187,9 +188,14 @@
def with_request(request, &block)
Thread.current[:__honeybadger_request] = request
yield
ensure
Thread.current[:__honeybadger_request] = nil
+ end
+
+ def request_hash
+ return DEFAULT_REQUEST_HASH unless request
+ Rack::RequestHash.new(request)
end
def params_filters
self[:'request.filter_keys'] + rails_params_filters
end