Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ibraheemdev/mongo_beautiful_logger
A simple and beautiful logger gem for MongoDB in you Ruby/Rails app.
https://github.com/ibraheemdev/mongo_beautiful_logger
beautiful logger mongo mongodb mongoid rails ruby ruby-on-rails
Last synced: about 1 month ago
JSON representation
A simple and beautiful logger gem for MongoDB in you Ruby/Rails app.
- Host: GitHub
- URL: https://github.com/ibraheemdev/mongo_beautiful_logger
- Owner: ibraheemdev
- License: mit
- Created: 2020-07-12T23:25:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-01T00:22:22.000Z (over 1 year ago)
- Last Synced: 2024-11-28T13:22:45.141Z (about 2 months ago)
- Topics: beautiful, logger, mongo, mongodb, mongoid, rails, ruby, ruby-on-rails
- Language: Ruby
- Homepage:
- Size: 15.5 MB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Mongo Beautiful Logger
[![](https://img.shields.io/gem/dt/mongo_beautiful_logger?style=for-the-badge)](https://rubygems.org/gems/mongo_beautiful_logger)
[![](https://img.shields.io/gem/v/mongo_beautiful_logger?style=for-the-badge)](https://rubygems.org/gems/mongo_beautiful_logger)
[![](https://img.shields.io/badge/License-MIT-blue?style=for-the-badge)](https://github.com/ibraheemdev/mongo_beautiful_logger/blob/master/LICENSE.txt)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:
```ruby
gem 'mongo_beautiful_logger'
```And then run:
```bash
$ bundle install
```Or you can install it manually:
```bash
$ 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:
```ruby
# 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:
```ruby
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](https://github.com/ibraheemdev/mongo_beautiful_logger/issues/new) or submit a pull request. Contributions are greatly appreciated.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).