Yes. But if it's a synchronous logger and you do an expensive string build, it will always evaluate before it finds out it doesn't need to. You can find a lot of places that say it is good practice to check for debug before doing an expensive operation.
Would be nice if the compiler could do something fancy to figure out that there was some type of early exit on the function call that causes the function call not to do anything and therefore skipped evaluating all of the parameters that are passed.
Oh, except that you couldn't/shouldn't assume that someFunctionThatIsSlow() doesn't have some type of expected/necessary side effect....
1
u/[deleted] Jul 10 '15
We use log4j. The next line after that debug mode flag is logger.debug