Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Way to copy a logger's context onto a logger with a different name #856

Open
timbertson opened this issue Jul 6, 2024 · 1 comment
Open

Comments

@timbertson
Copy link

timbertson commented Jul 6, 2024

I have two loggers, let's say they're named rpc and eval.

I want to handoff processing from the rpc to eval module, but my rpc logger has request info in its context, which I want to include when I make logging calls from the eval logger.

#238 is one solution, I could copy my rpc logger and also name it eval. Alternatively, if there was a way to extract the context from a logger I could either pass that around detached from the original logger, or write a function which adopted the context from a passed-in logger.

@timbertson
Copy link
Author

Another way to achieve this might be to have an implicit context object, which each log call accepts, and includes that context with the log statement. That way you pass around the context, and pair it with your module / class-level logger.

That would save you from having to build a fresh logger each time execution changes hands between modules. But maybe the ergonomics get awkward, as there's now 2 (or 3?) ways to inject context.

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

No branches or pull requests

1 participant