mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
This moves the instance of the logger class to a class variable in the `FloatyLogger` class and provides three class methods to log with in the rest of the project `FloatyLogger.info`, `FloatyLogger.warn`, and `FloatyLogger.error`.
27 lines
461 B
Ruby
27 lines
461 B
Ruby
require 'logger'
|
|
|
|
class FloatyLogger < ::Logger
|
|
def self.logger
|
|
@@logger ||= FloatyLogger.new
|
|
end
|
|
|
|
def self.info(msg)
|
|
FloatyLogger.logger.info msg
|
|
end
|
|
|
|
def self.warn(msg)
|
|
FloatyLogger.logger.warn msg
|
|
end
|
|
|
|
def self.error(msg)
|
|
FloatyLogger.logger.error msg
|
|
end
|
|
|
|
def initialize
|
|
super(STDERR)
|
|
self.level = ::Logger::INFO
|
|
self.formatter = proc do |severity, datetime, progname, msg|
|
|
"#{msg}\n"
|
|
end
|
|
end
|
|
end
|