Class: Contrast::Components::Logger::Interface

Inherits:
Object
  • Object
show all
Includes:
ComponentBase, InstanceMethods
Defined in:
lib/contrast/components/logger.rb

Overview

So This class here follows the update for the configuration and from know on ( if it’s as we planned it to be) it will hold the instance methods and will initialize new instances for where they’re needed

Constant Summary collapse

DEFAULT_NAME =
'contrast.log'
DEFAULT_LEVEL =
'INFO'
CANON_NAME =
'agent.logger'
CONFIG_VALUES =
%w[path level progname].cs__freeze

Constants included from ComponentBase

ComponentBase::ENABLE

Constants included from Contrast::Config::Diagnostics::Tools

Contrast::Config::Diagnostics::Tools::CHECK

Constants included from Contrast::Config::Diagnostics::SingletonTools

Contrast::Config::Diagnostics::SingletonTools::API_CREDENTIALS, Contrast::Config::Diagnostics::SingletonTools::CONTRAST_MARK

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ComponentBase

#false?, #file_exists?, #stringify_array, #true?, #valid_cert?

Methods included from Contrast::Config::Diagnostics::Tools

#add_effective_config_values, #add_single_effective_value

Methods included from Contrast::Config::Diagnostics::SingletonTools

#flatten_settings, #to_config_values, #update_config, #value_to_s

Methods included from InstanceMethods

#cef_logger, #logger

Constructor Details

#initialize(hsh = {}) ⇒ Interface

Returns a new instance of Interface.



52
53
54
55
56
57
58
59
60
# File 'lib/contrast/components/logger.rb', line 52

def initialize hsh = {}
  @config_values = CONFIG_VALUES
  @canon_name = CANON_NAME
  return unless hsh

  @path = hsh[:path]
  @level = hsh[:level]
  @progname = hsh[:progname]
end

Instance Attribute Details

#canon_nameString (readonly)

Returns:



48
49
50
# File 'lib/contrast/components/logger.rb', line 48

def canon_name
  @canon_name
end

#config_valuesArray (readonly)

Returns:

  • (Array)


50
51
52
# File 'lib/contrast/components/logger.rb', line 50

def config_values
  @config_values
end

#levelString?

Returns:



44
45
46
# File 'lib/contrast/components/logger.rb', line 44

def level
  @level
end

#pathString?

Returns:



42
43
44
# File 'lib/contrast/components/logger.rb', line 42

def path
  @path
end

#prognameString?

Returns:



46
47
48
# File 'lib/contrast/components/logger.rb', line 46

def progname
  @progname
end

Instance Method Details

#to_effective_config(effective_config) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/contrast/components/logger.rb', line 62

def to_effective_config effective_config
  path_setting = nil
  level_setting = nil

  if defined?(Contrast::SETTINGS)
    path_setting = Contrast::SETTINGS.agent_state.logger_path
    level_setting = Contrast::SETTINGS.agent_state.logger_level
  end

  path_setting ||= DEFAULT_NAME
  level_setting ||= DEFAULT_LEVEL

  add_single_effective_value(effective_config, config_values[0], path || path_setting, CANON_NAME)
  add_single_effective_value(effective_config, config_values[1], level || level_setting, CANON_NAME)
  add_single_effective_value(effective_config, config_values[2], progname, CANON_NAME)
end