lib/sapience/configuration.rb in sapience-2.4.0 vs lib/sapience/configuration.rb in sapience-2.5.0
- old
+ new
@@ -1,5 +1,6 @@
+# frozen_string_literal: true
require "ostruct"
module Sapience
# rubocop:disable ClassVars
@@ -21,14 +22,14 @@
}.freeze
# Initial default Level for all new instances of Sapience::Logger
def initialize(options = {}) # rubocop:disable AbcSize
fail ArgumentError, "options need to be a hash #{options.inspect}" unless options.is_a?(Hash)
- @options = DEFAULT.merge(options.dup.deep_symbolize_keyz!)
+ @options = DEFAULT.merge(options.dup.deep_symbolize_keyz!)
@options[:log_executor] &&= @options[:log_executor].to_sym
validate_log_executor!(@options[:log_executor])
- self.default_level = @options[:log_level].to_sym
+ self.default_level = @options[:log_level].to_sym
self.backtrace_level = @options[:log_level].to_sym
self.host = @options[:host]
self.app_name = @options[:app_name]
self.ap_options = @options[:ap_options]
self.appenders = @options[:appenders]
@@ -50,11 +51,11 @@
LEVELS[level_index]
end
# Internal method to return the log level as an internal index
# Also supports mapping the ::Logger levels to Sapience levels
- def level_to_index(level) # rubocop:disable AbcSize, PerceivedComplexity, CyclomaticComplexity
+ def level_to_index(level)
return if level.nil?
case level
when Symbol
LEVELS.index(level)
@@ -87,10 +88,9 @@
end
def default_level_index
Thread.current[:sapience_silence] || @default_level_index
end
-
# Sets the level at which backtraces should be captured
# for every log message.
#
# By enabling backtrace capture the filename and line number of where