Class: RailsSemanticLogging::Configuration
- Inherits:
-
Anyway::Config
- Object
- Anyway::Config
- RailsSemanticLogging::Configuration
- Defined in:
- lib/rails_semantic_logging/configuration.rb
Constant Summary collapse
- DEFAULT_LOG_TAGS =
{ request_id: :request_id, client_ip: :remote_ip }.freeze
- VALID_LOG_LEVELS =
%w[DEBUG INFO WARN ERROR FATAL UNKNOWN].freeze
Instance Method Summary collapse
-
#effective_log_tags ⇒ Object
Merges built-in default tags with app-provided custom tags.
-
#formatter_for(env) ⇒ Object
Returns the appropriate formatter for the given environment.
-
#log_level_for(env) ⇒ Object
Returns the appropriate log level for the given environment, respecting LOG_LEVEL env var.
Instance Method Details
#effective_log_tags ⇒ Object
Merges built-in default tags with app-provided custom tags
24 25 26 |
# File 'lib/rails_semantic_logging/configuration.rb', line 24 def DEFAULT_LOG_TAGS.merge() end |
#formatter_for(env) ⇒ Object
Returns the appropriate formatter for the given environment
29 30 31 32 33 34 35 36 |
# File 'lib/rails_semantic_logging/configuration.rb', line 29 def formatter_for(env) case env.to_s when 'production' resolve_formatter(production_formatter) || RailsSemanticLogging::Formatters::Datadog.new else resolve_formatter(development_formatter) || :color end end |
#log_level_for(env) ⇒ Object
Returns the appropriate log level for the given environment, respecting LOG_LEVEL env var
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rails_semantic_logging/configuration.rb', line 39 def log_level_for(env) default_level = case env.to_s when 'development' then 'DEBUG' when 'test' then 'FATAL' else 'INFO' end requested = ENV.fetch('LOG_LEVEL', default_level).to_s.upcase VALID_LOG_LEVELS.include?(requested) ? requested : default_level end |