loguru icon indicating copy to clipboard operation
loguru copied to clipboard

Support Template Strings for log messages (#1397)

Open TurtleOrangina opened this issue 2 months ago • 2 comments

Implements support for python 3.14 template strings:

logger.debug(t"obj = {large_obj}")

Will evaluate lazily, e.g. if the minimum log level means no debug messages are logged, the large_obj will not be converted to string.

TurtleOrangina avatar Oct 07 '25 11:10 TurtleOrangina

Thank you for this initial implementation. This seems like an excellent solution to compensate for the planned removal of **kwargs as a formatting argument.

Please allow me not to merge this PR immediately because I want to think a little about possible integrations of t-strings, but it seems very fine to me as is.

Delgan avatar Oct 08 '25 17:10 Delgan

Of course! Let me know if you want any changes.

TurtleOrangina avatar Oct 09 '25 07:10 TurtleOrangina

2 month reminder :). I read in a different PR that you are working on some larger refactoring, but wouldn't it make sense to get the simpler things that are already ready merged and maybe make a minor release with them? I would sure enjoy the ability to use logger.debug(t"obj = {large_obj}") in my python 3.14 projects :).

TurtleOrangina avatar Dec 08 '25 08:12 TurtleOrangina