Class: RequestHeadersLogger::Configuration
- Inherits:
-
Object
- Object
- RequestHeadersLogger::Configuration
- 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
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #log_format ⇒ Object
- #tag_format ⇒ Object
Constructor Details
#initialize ⇒ Configuration
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
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_format ⇒ Object
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_format ⇒ Object
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 |