Monday, 29 December 2014

Use logger.debug rather than puts!

It is often tempting to use puts in the ruby code to debug the informations.

I like logging instead because:
-allows the filtering capability
-allows formatting abilities
-with a little tweak it takes the same amount of effort than puts
-it is an already invented and well tested system

It is much better in short. So whenever is a logger system available I use that.

logger.debug 'doing this and that'

It seem to me too much to type at first, therefore I created a sublime logger snippet which accelerated typing. I created another one for those cases where I need to implicitly reference the Rails.logger.