The ruby logger class has two forms- one with method params, and one with a
block. They are different as the block form is lazy evaulated, and only
evaulated if the log level is actually enabled.
We can use this block form logger, as well as the logger.info? guard, to save
ourselves from building several log messages if we aren't actually going to
send or print them somewhere. This should have no effect whatsoever on the
contents of logs, it simply saves the overhead of string operations if we
aren't actually logging.
The ruby logger class has two forms- one with method params, and one with a block. They are different as the block form is lazy evaulated, and only evaulated if the log level is actually enabled.
We can use this block form logger, as well as the
logger.info?
guard, to save ourselves from building several log messages if we aren't actually going to send or print them somewhere. This should have no effect whatsoever on the contents of logs, it simply saves the overhead of string operations if we aren't actually logging.http://brian.pontarelli.com/2006/07/03/ruby-logging-and-performance/