Class: ScoutApm::Logging::Config

Inherits:
Config
  • Object
show all
Defined in:
lib/scout_apm/logging/config.rb

Overview

Holds the configuration values for Scout APM Logging.

Defined Under Namespace

Classes: ConfigDefaults

Constant Summary collapse

KNOWN_CONFIG_OPTIONS =
%w[
  config_file
  log_level
  log_stderr
  log_stdout
  log_file_path
  log_class
  logs_monitor
  logs_ingest_key
  logs_capture_level
  logs_config
  logs_reporting_endpoint
  logs_reporting_endpoint_http
  logs_proxy_log_dir
  logs_log_file_size
].freeze
SETTING_COERCIONS =
{
  'logs_monitor' => BooleanCoercion.new,
  'logs_log_file_size' => IntegerCoercion.new
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.with_file(context, file_path = nil, config = {}) ⇒ Object



77
78
79
80
81
82
83
84
85
# File 'lib/scout_apm/logging/config.rb', line 77

def self.with_file(context, file_path = nil, config = {})
  overlays = [
    ConfigEnvironment.new,
    ConfigFile.new(context, file_path, config),
    ConfigDefaults.new,
    ConfigNull.new
  ]
  new(context, overlays)
end

.without_file(context) ⇒ Object

The bootstrapped, and initial config that we attach to the context. Will be swapped out by both the monitor and manager on initialization to the one with a file (which also has the dynamic and state configs).



68
69
70
71
72
73
74
75
# File 'lib/scout_apm/logging/config.rb', line 68

def self.without_file(context)
  overlays = [
    ConfigEnvironment.new,
    ConfigDefaults.new,
    ConfigNull.new
  ]
  new(context, overlays)
end

Instance Method Details

#all_settingsObject



104
105
106
107
108
109
# File 'lib/scout_apm/logging/config.rb', line 104

def all_settings
  KNOWN_CONFIG_OPTIONS.inject([]) do |memo, key|
    o = overlay_for_key(key)
    memo << { key: key, value: value(key).inspect, source: o.name }
  end
end

#value(key) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/scout_apm/logging/config.rb', line 87

def value(key)
  unless KNOWN_CONFIG_OPTIONS.include?(key)
    logger.debug("Requested looking up a unknown configuration key: #{key} (not a problem. Evaluate and add to config.rb)")
  end

  o = overlay_for_key(key)
  raw_value = if o
                o.value(key)
              else
                # No overlay said it could handle this key, bail out with nil.
                nil
              end

  coercion = SETTING_COERCIONS.fetch(key, NullCoercion.new)
  coercion.coerce(raw_value)
end