# Log\_buddy released - your helpful dev and debug buddy

**URL:** <https://www.ruby-forum.com/t/log-buddy-released-your-helpful-dev-and-debug-buddy/133386>\
**Category:** Ruby\
**Created:** [March 31, 2008, 5:47am UTC](https://www.ruby-forum.com/t/log-buddy-released-your-helpful-dev-and-debug-buddy/133386 "2008-03-31T05:47:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [March 31, 2008, 5:47am UTC](https://www.ruby-forum.com/t/log-buddy-released-your-helpful-dev-and-debug-buddy/133386/1 "2008-03-31T05:47:51Z")

</div>

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](http://opensource.thinkrelevance.com/wiki/log_buddy)  
Source: [GitHub - relevance/log\_buddy: logbuddy is your friendly little log buddy by your side](http://github.com/relevance/log_buddy/tree/master)  
git clone git://github.com/relevance/log\_buddy.git  
rdocs: [http://thinkrelevance.rubyforge.org/log\_buddy/](http://thinkrelevance.rubyforge.org/log_buddy/)

# Thanks

Thanks to Dave T. 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

> **[Home](https://robsanheim.com/)**
>
> Just another WordPress site

> **[Cognitect, a Nu Holdings, Ltd. Company](https://cognitect.com/)**

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [March 31, 2008, 6:42am UTC](https://www.ruby-forum.com/t/log-buddy-released-your-helpful-dev-and-debug-buddy/133386/2 "2008-03-31T06:42:24Z")

</div>

On Mon, Mar 31, 2008 at 12:47:20PM +0900, Rob S. wrote:

> 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 growing ubiquity of all administrative commands being explained with  
a “sudo” at the front, as if everyone in the world uses sudo for all  
administrative commands, is getting kinda old.

1. Some people use MS Windows.

2. Some people use MacOS X.

3. Some people use su or just login as root from the TTY console.

The common thread here is that not everyone in the world is using  
Ubuntu.

. . . but LogBuddy looks interesting. I might have to give that a whirl  
in the near future. Thanks.

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [March 31, 2008, 6:57am UTC](https://www.ruby-forum.com/t/log-buddy-released-your-helpful-dev-and-debug-buddy/133386/3 "2008-03-31T06:57:05Z")

</div>

Chad P. wrote:

> The common thread here is that not everyone in the world is using Ubuntu.

1. Some people use ubuntu, but chown -R /usr/local to their own user.  
(On my laptop, anyway!) Never have to “sudo gem”.

---

<div class="post-metadata">

**Author:** ![rsanheim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/47e85d/32.png) [@rsanheim](https://www.ruby-forum.com/u/rsanheim)\
**Post date:** [March 31, 2008, 7:22am UTC](https://www.ruby-forum.com/t/log-buddy-released-your-helpful-dev-and-debug-buddy/133386/4 "2008-03-31T07:22:20Z")

</div>

Erm, Mac OS X uses sudo…

–Jeremy

On Mon, Mar 31, 2008 at 12:41 AM, Chad P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> a “sudo” at the front, as if everyone in the world uses sudo for all  
> . . . but LogBuddy looks interesting. I might have to give that a whirl  
> in the near future. Thanks.
> 
> –  
> CCD CopyWrite Chad P. [[http://ccd.apotheon.org](http://ccd.apotheon.org) ]  
> Thomas McCauley: “The measure of a man’s real character is what he would do  
> if he knew he would never be found out.”

–  
[http://jeremymcanally.com/](http://jeremymcanally.com/)  
[http://entp.com](http://entp.com)

Read my books:  
Ruby in Practice ([Ruby in Practice](http://manning.com/mcanally/))  
My free Ruby e-book ([http://humblelittlerubybook.com/](http://humblelittlerubybook.com/))

Or, my blogs:

> **[Site not found · DreamHost](http://mrneighborly.com)**
>
> The owner of this domain has not yet uploaded their website.

[http://rubyinpractice.com](http://rubyinpractice.com)
