Class: RequestHeadersLogger::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/request_headers_logger/configuration.rb

Defined Under Namespace

Classes: InvalidKey

Constant Summary collapse

CONFIG_KEYS =
[
  :log_format, # [logger_format] default or json
  :loggers,    # [Loggers]  List of all loggers used.
  :tag_format, # [tag_format]
].freeze
LOG_FORMATS =
%w[text json].freeze
TAG_FORMATS =
%w[val key_val].freeze

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



20
21
22
23
24
25
26
# File 'lib/request_headers_logger/configuration.rb', line 20

def initialize
  @configs = {
    log_format: LOG_FORMATS.first,
    loggers: [],
    tag_format: TAG_FORMATS.first
  }
end

Instance Method Details

#[](key) ⇒ Object



34
35
36
# File 'lib/request_headers_logger/configuration.rb', line 34

def [](key)
  @configs[key]
end

#[]=(key, value) ⇒ Object

Raises:



28
29
30
31
32
# File 'lib/request_headers_logger/configuration.rb', line 28

def []=(key, value)
  raise InvalidKey, key unless CONFIG_KEYS.include?(key)

  @configs[key] = value
end

#log_formatObject



38
39
40
# File 'lib/request_headers_logger/configuration.rb', line 38

def log_format
  LOG_FORMATS.include?(@configs[:log_format]) ? @configs[:log_format] : LOG_FORMATS.first
end

#tag_formatObject



42
43
44
# File 'lib/request_headers_logger/configuration.rb', line 42

def tag_format
  TAG_FORMATS.include?(@configs[:tag_format]) ? @configs[:tag_format] : TAG_FORMATS.first
end