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