Is there a way to do lazy evaluation when logging?
For instance console.log("Result: ", throwingFunc()) won't log the first argument ("Result: "), as the 2nd argument, throwingFunc(), will get evaluated before the call to console.log(..).
I also tried logger.debug("Result: ", () => throwingFunc()) with log4js and other libraries, but to my surprise none of them worked...
You can check the logger functions' arguments and when one or more of them are function and do a trial run of them before logging. Something like: