Class: Freighter::Logger
- Inherits:
-
Object
- Object
- Freighter::Logger
- Defined in:
- lib/freighter/logger.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #config_error(str) ⇒ Object
- #error(str) ⇒ Object
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
8 9 10 11 |
# File 'lib/freighter/logger.rb', line 8 def initialize @logger = ::Logger.new(STDOUT) logger.formatter = ->(severity, time, progname, msg) { "#{severity}: #{msg}\n" } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
13 14 15 16 |
# File 'lib/freighter/logger.rb', line 13 def method_missing(meth, *args, &block) logger.level = OPTIONS.verbose ? ::Logger::DEBUG : ::Logger::INFO logger.send(meth, *args) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/freighter/logger.rb', line 6 def logger @logger end |
Instance Method Details
#config_error(str) ⇒ Object
18 19 20 |
# File 'lib/freighter/logger.rb', line 18 def config_error(str) error "Config error: #{str} not defined" end |
#error(str) ⇒ Object
22 23 24 25 26 |
# File 'lib/freighter/logger.rb', line 22 def error(str) logger.error str logger.error "Freighter hit an iceburg. To the life boats. All is lost. A truely unfortunate day in nautical affairs :(" exit -1 end |