Class: PuppetDBCLI::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/puppetdb_cli/logger.rb

Overview

A logger for the PuppetDB CLI

Overrides standard format of logs for better cli ouput, but reverts to traditional log formatting when in debug mode

Instance Method Summary collapse

Constructor Details

#initializeLogger

Returns a new instance of Logger.


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/puppetdb_cli/logger.rb', line 16

def initialize
  super($stderr)

  self.formatter = proc do |severity, datetime, _progname, msg|
    if level == ::Logger::DEBUG
      "[#{datetime.strftime '%Y-%m-%d %H:%M:%S.%6N'}] #{severity} -- #{msg}\n"
    else
      "#{severity}: #{msg}\n"
    end
  end

  self.level = ::Logger::INFO
end

Instance Method Details

#enable_debug_modeObject


30
31
32
33
# File 'lib/puppetdb_cli/logger.rb', line 30

def enable_debug_mode
  self.level = ::Logger::DEBUG
  debug 'Debug mode enabled'
end