Open timbertson opened 2 months ago
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.
I have two loggers, let's say they're named
rpc
andeval
.I want to handoff processing from the
rpc
toeval
module, but myrpc
logger has request info in its context, which I want to include when I make logging calls from theeval
logger.238 is one solution, I could copy my
rpc
logger and also name iteval
. 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.