f-string with equals is great but how do I log it at debug level
Python 3.8 added f'{x=}' which prints x=42. I use it constantly while debugging but it hardcodes to stdout. Is there a way to route that to the logging module at DEBUG level so I don't have to strip them all out before committing? I'm on 3.11. I know about logging.debug(f'{x=}') but that still evaluates the f-string even when debug logging is off, which is the whole thing I'm trying to avoid.
4 replies