Module: Logging

Included in:
Gergich, Gergich::Commit
Defined in:
lib/logging.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.log_levelObject



20
21
22
23
# File 'lib/logging.rb', line 20

def self.log_level
  # default to only showing errors
  ENV.fetch("RUBY_LOG_LEVEL", "ERROR")
end

.loggerObject



10
11
12
13
14
15
16
17
18
# File 'lib/logging.rb', line 10

def self.logger
  @logger ||= Logger.new($stdout)
  @logger.formatter = proc do |severity, datetime, _progname, msg|
    datefmt = datetime.strftime("%Y-%m-%d %H:%M:%S")
    # ensure that there is only one newline at the end of the message
    "#{severity} [#{datefmt}]: #{msg}\n".gsub!(/\n+/, "\n")
  end
  @logger
end

Instance Method Details

#loggerObject



6
7
8
# File 'lib/logging.rb', line 6

def logger
  Logging.logger
end