Null Logger
A simple logger that does not log anything. It can be used for defining an interface for other loggers.
Installation
Add the gem to your Gemfile
gem 'null-logger', require: 'null_logger'
Usage
On NullLogger instance you can call methods which correspond to Ruby Logger log levels (unknown, fatal, error, warn, info, debug), ex:
NullLogger.new.fatal # return nil
NullLogger.new.wrong_method # raise NoMethodError
NullLogger defines an interface for real logger instance, ex:
class Worker
class << self
attr_writer :logger
def logger
@logger ||= NullLogger.new
end
def method()
# some code
rescue => exception
self.class.logger.fatal(exception)
raise exception
end
end
end
References
Note on contributions
First, thank you for considering contributing to NullLogger! It's people like you that make the open source community such a great community!
Each pull request must pass all the RSpec specs and meet our quality requirements.
To check if everything is as it should be, we use Coditsu that combines multiple linters and code analyzers for both code and documentation. Once you're done with your changes, submit a pull request.
Coditsu will automatically check your work against our quality standards. You can find your commit check results on the builds page of NullLogger repository.