Loog is an object-oriented logging wrapper around Ruby
Logger.
First, install it:
gem install loogThen, 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'))You can also truncate long messages with Loog::Ellipsized:
require 'loog'
require 'loog/ellipsized'
loog = Loog::Ellipsized.new(Loog::VERBOSE, 20)
loog.info('This is a very long message that will be truncated')
# prints: "This is...truncated"You can add ANSI colors to log messages with Loog::Colorful,
which prints debug messages in dark gray, warnings in orange,
and errors in red:
require 'loog'
require 'loog/colorful'
loog = Loog::Colorful.new(Loog::VERBOSE)
loog.debug('This is dark gray')
loog.warn('This is orange')
loog.error('This is red')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 rakeIf it's clean and you don't see any error messages, submit your pull request.