composite_logger

Logging using the Composite pattern.


License
MIT
Install
gem install composite_logger -v 1.2.0

Documentation

Composite Logger

Build Status Code Climate Dependency Status

One log to rule them all.

Installation

Add this line to your application's Gemfile:

gem "composite_logger"

And then execute:

$ bundle

Or install it yourself as:

$ gem install composite_logger

Usage

CompositeLogger implements the standard Logger interface so it can be a drop-in replacement for your current logger:

require "composite_logger"

stdout_logger = Logger.new(STDOUT)
stderr_logger = Logger.new(STDERR)
file_logger = Logger.new("logfile.log")

stdout_logger.level = Logger::DEBUG
stdout_logger.level = Logger::ERROR
file_logger.level = Logger::ERROR

composite_logger = CompositeLogger.new(stdout_logger, stderr_logger)
composite_logger.loggers << file_logger
composite_logger.level = Logger::INFO

composite_logger.debug("This won't be logged becase logger level is INFO")
composite_logger.info("This will be logged")
composite_logger << "Message using 'dump' syntax"
composite_logger.error do
  "An error message using block syntax"
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fertapric/composite_logger. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Author

Fernando Tapia Rico, @fertapric