stdlogger

Build Status

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.

Usage

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:

gem 'stdlogger'

And then run bundle command on your terminal.

Or install it yourself as:

% gem install stdlogger

Spetial Thanks

Thanks to David who gave me the idea of MultiIO.

It is illustrated as answer to a question in Stack Overflow.

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

License

The MIT License (MIT)

Copyright (c) 2016 YASUTAKE Kiyoshi