Class: Logged::Configuration

Inherits:
ActiveSupport::OrderedOptions
  • Object
show all
Defined in:
lib/logged/configuration.rb

Overview

logged configuration

Defined Under Namespace

Classes: ComponentOptions, LoggerOptions

Constant Summary collapse

DEFAULT_VALUES =

Default values for configuration options

{
  enabled:       false,
  level:         nil,
  formatter:     nil,
  ignore:        -> { [] },
  tags:          -> { [] },
  custom_ignore: nil,
  custom_data:   nil
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



48
49
50
51
52
53
54
# File 'lib/logged/configuration.rb', line 48

def initialize
  super { |hash, key| hash[key] = ComponentOptions.new }

  Configuration.init_default_options(self)

  self.loggers = ::ActiveSupport::OrderedOptions.new { |hash, key| hash[key] = LoggerOptions.new }
end

Class Method Details

.init_default_options(config, ignore_defaults = []) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/logged/configuration.rb', line 17

def self.init_default_options(config, ignore_defaults = [])
  DEFAULT_VALUES.each do |key, value|
    next if ignore_defaults.include?(key)

    if value.is_a?(Proc)
      config[key] = value.call
    else
      config[key] = value
    end
  end
end