Skip to content

yegor256/loog

Repository files navigation

Object-Oriented Logger for Ruby

EO principles respected here DevOps By Rultor.com We recommend RubyMine

rake Gem Version Maintainability Yard Docs Test Coverage Hits-of-Code

Loog is an object-oriented logging wrapper around Ruby Logger.

First, install it:

gem install loog

Then, use it like this:

require 'loog'
Loog::VERBOSE.info('Hello, world!')

The gem is basically a provider of a few pre-configured loggers, which you can use for production (Loog::REGULAR) or for testing (Loog::VERBOSE). You can also shut it up with Loog::NULL.

There is also Loog::Buffer class that you can use for testing. It accumulates all log calls and then returns the entire output through the to_s() method.

Also, you can "tee" two loogs, with the help of Loog::Tee. For example, to record everything in a buffer and also show in the console:

require 'loog'
require 'loog/tee'
buf = Loog::Buffer.new
loog = Loog::Tee.new(Loog::VERBOSE, buf)
loog.info('Hello, world!')
assert(buf.to_s.include?('Hello'))

How to contribute

Read these guidelines. Make sure your build is green before you contribute your pull request. You will need to have Ruby 2.3+ and Bundler installed. Then:

bundle update
bundle exec rake

If it's clean and you don't see any error messages, submit your pull request.

About

Ruby object, which you can pass to other objects, where they will use it as a logger

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages