class Fit4Ruby::ILogger
The ILogger
class is a singleton that provides a common logging mechanism to all objects. It exposes essentially the same interface as the Logger class, just as a singleton and with some additional methods like ‘fatal’ and ‘cricital’.
Public Instance Methods
abort(msg, &block)
click to toggle source
Print an error message via the Logger and raise a Fit4Ruby::Abort
. This method should be used to abort the program in case of user errors.
# File lib/fit4ruby/Log.rb, line 60 def abort(msg, &block) @@logger.error(msg, &block) raise Abort, msg end
fatal(msg, &block)
click to toggle source
Print an error message via the Logger and raise a Fit4Ruby::Error
. This method should be used to abort the program in case of program logic errors.
# File lib/fit4ruby/Log.rb, line 68 def fatal(msg, &block) @@logger.error(msg, &block) raise Error, msg end
method_missing(method, *args, &block)
click to toggle source
Pass all calls to unknown methods to the @@logger object.
# File lib/fit4ruby/Log.rb, line 49 def method_missing(method, *args, &block) @@logger.send(method, *args, &block) end
open(io)
click to toggle source
Redirect all log messages to the given IO. @param io [IO] Output file descriptor
# File lib/fit4ruby/Log.rb, line 39 def open(io) begin @@logger = Logger.new(io) rescue => e @@logger = Logger.new($stderr) Log.fatal "Cannot open log file: #{e.message}" end end
respond_to?(method, include_private = false)
click to toggle source
Make it properly introspectable.
# File lib/fit4ruby/Log.rb, line 54 def respond_to?(method, include_private = false) @@logger.respond_to?(method) end