Skip to content

Support Template Strings for log messages (#1397)#1398

Open
TurtleOrangina wants to merge 1 commit intoDelgan:masterfrom
TurtleOrangina:support_template_strings
Open

Support Template Strings for log messages (#1397)#1398
TurtleOrangina wants to merge 1 commit intoDelgan:masterfrom
TurtleOrangina:support_template_strings

Conversation

@TurtleOrangina
Copy link

@TurtleOrangina TurtleOrangina commented Oct 7, 2025

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 TurtleOrangina force-pushed the support_template_strings branch from 025a55e to 8ebac5d Compare October 7, 2025 17:18
@TurtleOrangina TurtleOrangina force-pushed the support_template_strings branch from 8ebac5d to 5bcc344 Compare October 7, 2025 17:51
@Delgan
Copy link
Owner

Delgan commented Oct 8, 2025

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.

@TurtleOrangina
Copy link
Author

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

@TurtleOrangina
Copy link
Author

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 :).

@gipfelen
Copy link

Hi! Just checking in to see if there are any updates on this PR. It would be a handy addition for a project I’m currently working on. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants