require 'logger' module SentinelApi class Configuration attr_accessor :uri attr_accessor :level attr_accessor :method DEFAULT_URI = (ENV['SENTINEL_API_URI'] || 'http://localhost:3000/reports').freeze DEFAULT_METHOD = (ENV['SENTINEL_API_METHOD'] || 'post').freeze def initialize @uri = DEFAULT_URI @method = DEFAULT_METHOD end def merge(options) new_configuration = clone new_configuration.merge!(options) new_configuration end def merge!(options) options.each do |name, value| variable_name = "@#{name}" next unless instance_variable_defined?(variable_name) instance_variable_set(variable_name, value) end self end def default_logger @default_logger ||= defined?(::Rails) ? ::Rails.logger : ::Logger.new(STDERR) end def use_ssl? uri.match(/^https:/) ? true : false end end end