Module: LoggingConfiguration

Defined in:
lib/story_teller/logging.rb

Overview

The LoggingConfiguration module

Class Method Summary collapse

Class Method Details

.configObject

rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/story_teller/logging.rb', line 33

def config
  @config ||= begin
    module_dir_path = File.expand_path(__dir__)
    lib_dir_path = File.expand_path(File.dirname(module_dir_path))
    project_dir_path = File.expand_path(File.dirname(lib_dir_path))
    app_name = File.basename(project_dir_path)
    logs_dir_path = File.expand_path(File.join(project_dir_path, 'logs'))
    FileUtils.mkdir_p(logs_dir_path)
    log_file_path = File.expand_path(File.join(logs_dir_path, "#{app_name}.log"))
    FileUtils.touch(log_file_path)
    {
      level: ENV['INFORM_LOG_LEVEL']&.to_i || Logger::INFO,
      name: app_name,
      lib_dir_path: lib_dir_path,
      project_dir_path: project_dir_path,
      logs_dir_path: logs_dir_path,
      log_file_path: log_file_path,
      rolling_log_file_name_template: File.expand_path(
        File.join(logs_dir_path, "#{app_name}-%d{yyyy-MM-dd}.log.gz")),
      logging_timestamp_format: '%Y-%m-%d %H:%M:%S',
      logging_pattern_template: {
        java: '%d{ABSOLUTE} %-5p [%c{1}] %m%n',
        ruby: "%<timestamp>s %-5<severity>s [%<progname>s] %<msg>s\n"
      },
      schedule: '0 0 0 * * ?',
      size: '100M'
    }
  end
end