Rob Sanheim
2008-Mar-31 03:47 UTC
[ANN] log_buddy released - your helpful dev and debug buddy
LogBuddy is your friendly little log buddy at your side, helping you dev, debug, and test. It plays well with Rails and plain old Ruby projects. To use it, sudo gem install log_buddy, then require ''log_buddy'' and call LogBuddy.init. It will add two methods to object instance and class level: "d" and "logger". You probably only want to use these in non-prod environments, so conditionally load it based on your test env. The "logger" method is just a typical logger - it will use the Rails logger if its available. The "d" method is a special helper that will output the code in the block and its result - note that you *must* use the bracket block form - do...end is not supported. Examples ====== require ''lib/log_buddy'' LogBuddy.init a = "foo" @a = "my var" @@bar = "class var!" def bark "woof!" end module Foo; def self.module_method "hi!!" end end d { a } # logs "a = ''foo''" d { @a } # logs "@a = ''my var''" d { @@bar } # logs "@@bar = ''class var!''" d { bark } # logs "bark = woof!" d { Foo::module_method } # logs Foo::module_method = ''hi!!'' More ===Log bugs/issues/suggestions here: http://opensource.thinkrelevance.com/wiki/log_buddy Source: http://github.com/relevance/log_buddy/tree/master git clone git://github.com/relevance/log_buddy.git rdocs: http://thinkrelevance.rubyforge.org/log_buddy/ Thanks =====Thanks to Dave Thomas and his latest testing code for the idea of simple reading the file based on the call stack to easily output the log line. Thanks to Muness Alrubaie for pairing. - Rob http://robsanheim.com http://thinkrelevance.com