https://github.com/markbates/split_logger
Delegates logging calls to many loggers.
https://github.com/markbates/split_logger
Last synced: 12 months ago
JSON representation
Delegates logging calls to many loggers.
- Host: GitHub
- URL: https://github.com/markbates/split_logger
- Owner: markbates
- License: mit
- Created: 2009-09-21T20:43:01.000Z (almost 17 years ago)
- Default Branch: master
- Last Pushed: 2014-01-22T16:32:05.000Z (over 12 years ago)
- Last Synced: 2025-04-25T17:59:01.196Z (about 1 year ago)
- Language: Ruby
- Homepage: http://www.metabates.com
- Size: 145 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# SplitLogger
[](https://travis-ci.org/markbates/split_logger) [](https://codeclimate.com/github/markbates/split_logger)
This gem let's you write to multiple log destinations at the same time.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'split_logger'
```
And then execute:
```console
$ bundle
```
Or install it yourself as:
```console
$ gem install split_logger
```
## Usage
You can set up loggers in one of two ways:
```ruby
logger = SplitLogger.new
logger.add(std: Logger.new(STDOUT))
logger.add(file: Logger.new("/path/to/log"))
logger.level = ::Logger::INFO
logger.info "Hello Logs"
```
or you can pass them all into the initializer:
```ruby
logger = SplitLogger.new({
std: Logger.new(STDOUT),
file: Logger.new("/path/to/log")
})
logger.level = ::Logger::INFO
logger.info "Hello Logs"
```
### Rails
By default the Rails logger is automatically added when creating a new `SplitLogger`.
Of course, if you don't want the Rails logger it can easily be removed.
```ruby
logger.remove(:rails_default_logger)
```
## Contributing
1. Fork it ( http://github.com//split_logger/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request