Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A lock-free logger for Ruby 2.0

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore Initial commit.
Octocat-spinner-32 .travis.yml Add in supported rubies.
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile Add MRI tests for Logger.
Octocat-spinner-32 mono_logger.gemspec
README.md

MonoLogger

Build Status Code Climate Coverage Status

Ruby's stdlib Logger wraps all IO in mutexes. Ruby 2.0 doesn't allow you to request a lock in a trap handler because that could deadlock. This gem fixes this issue by giving you a lock-free logger class.

If you've ever seen log writing failed. can't be called from trap context, you're in the right place!

Installation

Add this line to your application's Gemfile:

gem 'mono_logger'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mono_logger

Usage

It's simple, just use MonoLogger anywhere you'd use Logger:

require 'logger'


logger = Logger.new(STDOUT)
logger.level = Logger::WARN

logger.debug("Created logger")
logger.info("Program started")
logger.warn("Nothing to do!")

Turns into

require 'mono_logger'


logger = MonoLogger.new(STDOUT)
logger.level = MonoLogger::WARN

logger.debug("Created logger")
logger.info("Program started")
logger.warn("Nothing to do!")

That's it! No more errors!

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

MIT. See LICENSE.txt for more details.

Something went wrong with that request. Please try again.