Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/progrhyme/ruby-stdlogger
Make Logger write to STDOUT in addition
https://github.com/progrhyme/ruby-stdlogger
Last synced: about 2 months ago
JSON representation
Make Logger write to STDOUT in addition
- Host: GitHub
- URL: https://github.com/progrhyme/ruby-stdlogger
- Owner: progrhyme
- License: mit
- Created: 2016-04-05T02:32:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-04-05T03:03:30.000Z (over 8 years ago)
- Last Synced: 2024-10-28T17:19:19.121Z (about 2 months ago)
- Language: Ruby
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# stdlogger
[![Gem Version](https://badge.fury.io/rb/stdlogger.svg)](https://badge.fury.io/rb/stdlogger)
[![Build Status](https://travis-ci.org/key-amb/ruby-stdlogger.svg?branch=master)](https://travis-ci.org/key-amb/ruby-stdlogger)This package enables to create `Logger` object which writes logs to _STDOUT_ in
addition to specified log device when _STDOUT_ is TTY.
And it can also write logs to _STDERR_ by option.Useful for Command-line Tools.
Rewritten from [logger-with_stdout](https://github.com/key-amb/logger-with_stdout).
## Usage
```ruby
require 'stdlogger'# STDOUT only
logger = StdLogger.create
# logfile and STDOUT
logger = StdLogger.create '/path/to/log'
# logdev and STDERR
logger = StdLogger.create io_obj, stdout: false, stderr: true
# Other options for Logger::new
logger = StdLogger.create io_obj, shift_age: 3, shift_size: 1024 * 1024 * 8
# Doesn't raise error when STDOUT is not TTY
logger = StdLogger.create nil, allow_nodev: true
```## Installation
Add this line to your application's Gemfile:
```ruby
gem 'stdlogger'
```And then run `bundle` command on your terminal.
Or install it yourself as:
```sh
% gem install stdlogger
```## Spetial Thanks
Thanks to [David](http://stackoverflow.com/users/796195/david) who gave me the
idea of `MultiIO`.It is illustrated as [answer to a question in Stack Overflow](http://stackoverflow.com/a/6407200/6150943).
## Contributing
1. Fork it
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](../../pull/new/master)## License
The MIT License (MIT)
Copyright (c) 2016 YASUTAKE Kiyoshi