Module: Logging
- Defined in:
- lib/mixins/logging.rb
Overview
Handles all logging output for Tefoji
Class Method Summary collapse
-
.logger(log_level) ⇒ Object
Do the actual logging by wrapping Logger gem.
Instance Method Summary collapse
-
#fatal(message) ⇒ Object
Another cheap hack to wrap 'logger' above.
-
#logger ⇒ Object
A cheap hack that will instantiate a logger if necessary before sending a log message.
Class Method Details
.logger(log_level) ⇒ Object
Do the actual logging by wrapping Logger gem.
20 21 22 23 24 25 26 27 28 |
# File 'lib/mixins/logging.rb', line 20 def self.logger(log_level) return @logger unless @logger.nil? @logger = Logger.new($stderr, progname: File.basename($PROGRAM_NAME), level: log_level) @logger.formatter = proc do |severity, _, script_name, | "#{script_name}: #{severity} #{message}\n" end return @logger end |
Instance Method Details
#fatal(message) ⇒ Object
Another cheap hack to wrap 'logger' above. Called as 'fatal' rather than 'logger.fatal' directly, does the exit for us so we can be lazy.
14 15 16 17 |
# File 'lib/mixins/logging.rb', line 14 def fatal() logger.fatal() exit 1 end |
#logger ⇒ Object
A cheap hack that will instantiate a logger if necessary before sending a log message. This is the normal interface to logging from outside.
8 9 10 |
# File 'lib/mixins/logging.rb', line 8 def logger Logging.logger(@log_level) end |