views:

166

answers:

1

From the Rails Guide on debugging, I found that I can customize output to my log files using this simple method:

logger.debug "Person attributes hash: #{@person.attributes.inspect}"

I decided use this to track how a variable changes and goes through flow control.

I would like to be able to see the line number of my code where logger#debug method was called. Something like this:

logger.debug "Person attributes hash: #{@person.attributes.inspect} from line #{LINE_NUMBER_VAR}"
+2  A: 

logger.debug "Person attributes hash: #{@person.attributes.inspect} from line #{LINE}"

UPD: parser eats up double underscores before and after LINE variable

_ _ LINE _ _ - just remove 4 extra spaces from this expression

DNNX
What do you mean by that update?
See my fisrt sentence. Stackoverflow's message parser don't shows two underscores in a row (hides them or eats up somehow else; maybe makes part of message between underscores bold).
DNNX
ok great! thanks! I didn't know you meant SO's parsers. so use this: http://dpaste.com/159599/