Open indigoviolet opened 1 year ago
Hi @indigoviolet,
I was thinking about adding a new method that does just that. Can you please share with me what your use case is that requires multiple independent loggers? It could help improve the design of Loguru.
Currently, the recommended workaround is to use copy.deepcopy(logger)
on a logger without sinks and then copy it whenever you need a new logger.
Regarding your remark about logger.bind()
/ filter
, wouldn't it be possible to first .remove()
the default handler?
copy.deepcopy(logger)
will fail if there are unpickleable handlers (https://loguru.readthedocs.io/en/stable/resources/recipes.html#creating-independent-loggers-with-separate-set-of-handlers).But
logger.remove()
will have a global effect.Is there any way to make an independent logger (so I can have separate handlers) without breaking the default logger?
Note that the
logger.bind()
/filter
doesn't quite do what I want because the default handler doesn't have a filter on it, so it gets everything.