Class: Jenkins2::Log

Inherits:
Object
  • Object
show all
Extended by:
SingleForwardable
Defined in:
lib/jenkins2/log.rb

Class Method Summary collapse

Class Method Details

.init(log: $stderr, verbose: 0) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jenkins2/log.rb', line 10

def self.init(log: $stderr, verbose: 0)
	log ||= $stderr
	@logger = Logger.new log
	@logger.level = Logger::ERROR - verbose.to_i
	@logger.formatter = proc do |severity, datetime, _progname, msg|
		if [$stdout, $stderr].include?(log)
			"#{msg}\n"
		else
			"[#{datetime.strftime '%FT%T%:z'}] #{severity} #{msg}\n"
		end
	end
	@logger
end

.loggerObject



26
27
28
# File 'lib/jenkins2/log.rb', line 26

def self.logger
	@logger ||= init
end