News for hackers. Stuff that matters.
Re:Logging in Python like a pro by andrewingram on Friday July 01, 2022 @01:53PM (#31950121)
ContextVars are seemingly more robust and work with async. We use them quite extensively for adding context to logs.
Re:Logging in Python like a pro by nerdwaller on Friday July 01, 2022 @02:14PM (#31950460)
I was going to say the same, I combine ContextVars with LoggerAdapters[1].

[1] https://docs.python.org/3/library/logging.html#logging.Logge...

Re:Logging in Python like a pro by MapleWalnut on Friday July 01, 2022 @04:49PM (#31952663)
TIL that ContextVars can work in place of thread locals too. Thanks for pointing that out!

I had mistakenly assumed ContextVars only worked for async code.