Module: TrackerHub::Request::Config::Logger

Defined in:
lib/tracker_hub/request/config/logger.rb

Overview

Default customizable configurations for normal/rolling logger

Constant Summary collapse

ROLLING_PATTERN =
'%Y-%m-%d-%H-%M-%S'.freeze
ROLLING_AGE =
'daily'.freeze
ROLLING_SIZE =
1.gigabyte.freeze
LOGGER_NAME =
'requests'.freeze
LOGFILE_NAME =
"#{LOGGER_NAME}.log".freeze

Class Method Summary collapse

Class Method Details

.default_configActiveSupport::Logger

Default configuration for the logger

Examples:

> logger = TrackerHub::Request::Config::Logger.default_config
> logger.info('log text')

Returns:

  • (ActiveSupport::Logger)


48
49
50
# File 'lib/tracker_hub/request/config/logger.rb', line 48

def default_config
  ::ActiveSupport::Logger.new(File.join(log_path, LOGFILE_NAME))
end

.rolling_logger(args = {}) ⇒ Logging::Logger

Template for the rolling logger configuration

Note: for additional options, please refer to:
http://www.rubydoc.info/gems/logging/Logging/Appenders/RollingFile:initialize

Examples:

> options = { logger_name: 'my_logger' }
> logger = TrackerHub::Request::Config::Logger.rolling_logger(options)
> logger.info('log text')

Parameters:

  • args (Hash) (defaults to: {})

    a customizable set of options

Options Hash (args):

  • :log_path (String) — default: '/log'

    Path of the log file

  • :logger_name (String) — default: 'requests'

    Name of the log file

  • :logfile_pattern (String) — default: 'requests.log.%Y-%m-%d-%H-%M-%S'

    Pattern to roll log files

  • :age (String|Integer) — default: 'daily'

    The maximum age (in seconds) of a log file before it is rolled.

  • :size (String) — default: 1073741824

    The maximum allowed size (in bytes) of a log file before it is rolled.

Returns:

  • (Logging::Logger)


33
34
35
36
37
# File 'lib/tracker_hub/request/config/logger.rb', line 33

def rolling_logger(args = {})
  options = extract_rolling_options(args)

  build_rolling_logger(options)
end