lib/sapience/configuration.rb in sapience-2.0.2 vs lib/sapience/configuration.rb in sapience-2.0.3

- old
+ new

@@ -2,17 +2,18 @@ module Sapience # rubocop:disable ClassVars class Configuration - attr_reader :default_level, :backtrace_level, :backtrace_level_index + attr_reader :default_level, :log_level_active_record, :backtrace_level, :backtrace_level_index attr_writer :host attr_accessor :app_name, :ap_options, :appenders, :log_executor, :filter_parameters, :metrics, :error_handler SUPPORTED_EXECUTORS = %i(single_thread_executor immediate_executor).freeze DEFAULT = { - log_level: :info, + log_level: :info, + log_level_active_record: :info, host: nil, ap_options: { multiline: false }, appenders: [{ stream: { io: STDOUT, formatter: :color } }], log_executor: :single_thread_executor, metrics: { datadog: { url: Sapience::DEFAULT_STATSD_URL } }, @@ -24,11 +25,12 @@ 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[: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.log_level_active_record = @options[:log_level_active_record].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] @@ -41,9 +43,16 @@ # Sets the global default log level def default_level=(level) @default_level = level # For performance reasons pre-calculate the level index @default_level_index = level_to_index(level) + end + + # Sets the active record log level + def log_level_active_record=(level) + @log_level_active_record = level + # For performance reasons pre-calculate the level index + @log_level_active_record_index = level_to_index(level) end # Returns the symbolic level for the supplied level index def index_to_level(level_index) LEVELS[level_index]