coderberry

Multi-Line Rails Logger Trick

One thing that I like to do with my logger output is allow for multi-line output. It makes it much easier to read and keeps my code cleaner.

Instead of doing this:

1
2
logger.info "Current Contest: #{@contest.name}"
logger.info "Current User: #{@contest.name}"

You can do this:

1
2
3
4
logger.info """
    Current Contest: #{@contest.name}
    Current User: #{@contest.name}
"""

Comments