Class: ReeLogger::Config

Inherits:
Object
  • Object
show all
Includes:
Ree::BeanDSL
Defined in:
lib/ree_lib/packages/ree_logger/package/ree_logger/config.rb

Constant Summary collapse

LEVELS =
%w[warn info debug error fatal unknown].freeze
RATE_LIMIT_INTERVAL =
60
RATE_LIMIT_MAX_COUNT =
600

Instance Method Summary collapse

Instance Method Details

#buildObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ree_lib/packages/ree_logger/package/ree_logger/config.rb', line 19

def build
  is_rollbar_enabled = parse_bool_string(ENV['LOG_ROLLBAR_ENABLED'])

  to_obj({
    file_path: ENV['LOG_FILE_PATH'],
    file_auto_flush: parse_bool_string(ENV['LOG_FILE_AUTO_FLUSH']),
    levels: {
      file: parse_level(ENV['LOG_LEVEL_FILE']),
      stdout: parse_level(ENV['LOG_LEVEL_STDOUT']),
      rollbar: is_rollbar_enabled ? parse_level(ENV['LOG_LEVEL_ROLLBAR']) : nil,
    },
    rollbar: {
      enabled: is_rollbar_enabled,
      access_token: is_rollbar_enabled ? ENV.fetch('LOG_ROLLBAR_ACCESS_TOKEN') : nil,
      environment: is_rollbar_enabled ? ENV.fetch('LOG_ROLLBAR_ENVIRONMENT') : nil,
      branch: ENV['LOG_ROLLBAR_BRANCH'],
      host: ENV['LOG_ROLLBAR_HOST']
    },
    rate_limit: {
      interval: get_int_value('LOG_RATE_LIMIT_INTERVAL', RATE_LIMIT_INTERVAL),
      max_count: get_int_value('LOG_RATE_LIMIT_MAX_COUNT', RATE_LIMIT_MAX_COUNT),
    },
    default_filter_words: %w[
      password token credential bearer authorization
    ]
  })
end