Is your feature request related to a problem? Please describe.
Sometimes while logging, you want to use logger.debug, but you end up formatting a message even if the message won't be logged. Would be nice to make the formatting of the message content itself lazy.
Could also do logger.debug(() => ''), just a plain old function. But the templating idea seems pretty useful, at the end of the day it does in fact return a function too. So if you're going to template something, returning a function to be called might be faster if there are lots of logger.debug calls going around.
Should benchmark if this really improves performance, but it also provides some usability... we might be more free to sprinkle logger.debug calls if they don't slow things down (except a function call).
Is your feature request related to a problem? Please describe.
Sometimes while logging, you want to use
logger.debug
, but you end up formatting a message even if the message won't be logged. Would be nice to make the formatting of the message content itself lazy.Describe the solution you'd like
Use something like:
Describe alternatives you've considered
Could also do
logger.debug(() => '')
, just a plain old function. But the templating idea seems pretty useful, at the end of the day it does in fact return a function too. So if you're going to template something, returning a function to be called might be faster if there are lots oflogger.debug
calls going around.Additional context
Should benchmark if this really improves performance, but it also provides some usability... we might be more free to sprinkle
logger.debug
calls if they don't slow things down (except a function call).