Module: Chimps::Log

Defined in:
lib/chimps/utils.rb

Overview

Module for initializing the Chimps logger from configuration settings.

Class Method Summary collapse

Class Method Details

.log_fileString, $stdout

Return either the path to the log file in Chimps.config or $stdout if the path is blank or equal to ‘-’.

Returns:

  • (String, $stdout)

    the path to the log or $stdout



46
47
48
49
50
51
52
# File 'lib/chimps/utils.rb', line 46

def self.log_file
  if Chimps.config[:log]
    Chimps.config[:log].strip == '-' ? $stdout : Chimps.config[:log]
  else
    $stdout
  end
end

.new_loggerLogger

Initialize a new Logger instance with the log level set by Chimps.verbose?

Returns:

  • (Logger)


34
35
36
37
38
39
40
# File 'lib/chimps/utils.rb', line 34

def self.new_logger
  require 'logger'
  Logger.new(log_file).tap do |log|
    log.progname = "Chimps"
    log.level    = Chimps.verbose? ? Logger::INFO : Logger::WARN
  end
end