Low commit activity in last 3 years
A long-lived project that still receives updates
A simple and beautiful logger for MongoDB/Mongoid in you Ruby/Rails app.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.7
~> 13.3
 Project Readme

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 install

Or you can install it manually:

$ gem install mongo_beautiful_logger

Usage

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.