RubyGems Navigation menu

tagged_logger 0.2.0

This gem supposed to help you to forget about how to expose logging facitilities to the code you write. Any time you want to log something, simply do one of: logger.debug("verbose debug information") #or logger.warn("warning") #or logger.info("information you frequently want to see") #or logger.error("errors") #or logger.fatal("fatal errors") and do not worry about where the '#logger' is and what it does at the moment, you will have a chance to configure it in place where you confugure other things. So you may focus on _what_ to put in the logging rather on how to set it up. Later you may turn logging on for specific class or bunch of classes or in case you have special logging demands for specific classes you also may specify it in very simple way. The simplest way to turn logging on for every class whose methods calls '#logger': TaggedLogger.rules do out_everything_to Logger.new(STDOUT) end or you may cook it in your special way: TaggedLogger.rules do out /.*/ do |level, tag, msg| puts "#{level}-#{tag}: #{msg}" end end Where 'tag' is the simple class name whose method calls '#logger'. Note, you do not have to implement '#logger' method anywhere. It gets automatically generated by specifying any of 'out' rules. You may be even more picky about what and where to log. Imagine you have 'Network' and 'Database' classes and you want to have separate log files for them, it is easy: TaggedLogger.rules do out Network => Logger.new("network.log") out Database => Logger.new("database.log") end In case you want to define common log for several classes: TaggedLogger.rules do out [Ftp, Http, Sockets] => Logger.new("network.log") end Or if you want to have all these classes showing up under common tag 'Network' in standard output: TaggedLogger.rules do out_everything_to Logger.new(STDOUT) rename [Ftp, Http, Sockets] => :Network end You may also use regular expressions in your rules: TaggedLogger.rules do out /Active::/ => Logger.new("active.log") end

Gemfile:
= Copy to clipboard Copied!

install:
=

Versions:

  1. 0.5.6 - October 28, 2012 (101 KB)
  2. 0.5.5 - November 02, 2010 (101 KB)
  3. 0.5.1 - October 30, 2010 (13.5 KB)
  4. 0.5.0 - October 29, 2010 (13 KB)
  5. 0.4.6 - October 23, 2010 (12.5 KB)
  6. 0.2.0 - December 20, 2009 (9.5 KB)
Show all versions (17 total)

Owners:

Authors:

  • Fedor Kocherga

SHA 256 checksum:

723b8fdf812136ddb6c970cfee2bd1b24621a072c0df022c7d2505cbcdaec320

Total downloads 56,601

For this version 3,311

Licenses:

N/A

Required Ruby Version: None

Links: