With classic logging you'd:
logger.debug("some var: %s", the_var)
so that a perhaps costly conversion or interpolation isn't payed if the log level isn't debug or trace.
How would we do the same with structured logging?
logger.debug("some var: %s", the_var, extras={})
could work for the message but what if I need it inside another field?
logger.debug({"key1": "%s", "key2": "%s"}, var1, var2)
This looks nasty.
Or is there already something in place I've missed?
With classic logging you'd:
so that a perhaps costly conversion or interpolation isn't payed if the log level isn't debug or trace.
How would we do the same with structured logging?
could work for the message but what if I need it inside another field?
This looks nasty.
Or is there already something in place I've missed?