Mongo Beautiful Logger
Have you ever started your rails console or log files and groaned when this is what you saw?
Mongo Beautiful Logger is simple and beautiful logging gem that converts that, into this:
Amazing, right?
Installation
Add this line to your application's Gemfile:
gem 'mongo_beautiful_logger'And then run:
$ bundle installOr you can install it manually:
$ gem install mongo_beautiful_loggerUsage
To set Mongo Beautiful Logger as the default logger for MongoDB, create a configuration file and add the following:
# config/initializers/mongo_logger.rb
require "mongo_beautiful_logger"
# MongoDB Driver:
Mongo::Logger.logger = MongoBeautifulLogger.new($stdout)
# Mongoid ODM:
Mongoid.logger = MongoBeautifulLogger.new($stdout)The MongoidBeautifulLogger class takes unlimited parameters which specify multiple output destinations. This can be used to output logs to a file as well as the console:
MongoBeautifulLogger.new($stdout, 'log.txt')Behavior
Mongo Beautiful logger automatically colors all mongodb actions (find, update, insert, delete, aggregate, error, endsession, failure). It will also filter out the redundant messages regarding topology events, and server description changes. If there are any other actions that you would like to be customized, you can open a github issue or submit a pull request. Contributions are greatly appreciated.
License
The gem is available as open source under the terms of the MIT License.

