Move logger instance to class var in FloatyLogger

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`.
This commit is contained in:
Austin Blatt 2020-08-12 09:49:15 -07:00
parent 8ec90007ca
commit 35faeab6be
7 changed files with 59 additions and 47 deletions

View file

@ -1,6 +1,22 @@
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
@ -8,4 +24,4 @@ class FloatyLogger < ::Logger
"#{msg}\n"
end
end
end
end