loguru icon indicating copy to clipboard operation
loguru copied to clipboard

Can I have multiple loggers?

Open mdelmans opened this issue 1 year ago • 4 comments

I'm running an async server and I want users to chose which sinks to use for logging, so I need to customise logger before passing it to an async function.

Is it possible to create multiple loguru._logger.Logger instances so there is no cross-talk between them? Is there a better approach?

mdelmans avatar Apr 25 '24 12:04 mdelmans

One way would be to use bind() but that requires the added sink to have a filter based on the bounded name.

Maybe you can use this workaround to create inepependent loggers until I implement a new() method: Creating independent loggers with separate set of handlers.

Delgan avatar May 02 '24 12:05 Delgan

Thanks, I think this should work.

mdelmans avatar May 02 '24 16:05 mdelmans

This answer as well as the question helps me a lot. Thx.

edx-h avatar Jun 13 '24 02:06 edx-h

Thanks, although I think a new() could be better. Thanks for the great library!

SuperKenVery avatar May 10 '25 02:05 SuperKenVery