loguru
loguru copied to clipboard
Adding two handlers with the same sink creates duplicated traces
Hello,
I realized that adding two handlers with the same sink (same file) creates duplicated traces.
For example, the code below:
from loguru import logger
logger.add("my.log", level="INFO")
logger.add("my.log", level="INFO")
logger.info("hello")
Will create the following output:

At some point, I understand that the behavior is correct. However, is there any way to only add a new handler if and only if there is not other handler with the same configuration?
Thank you.
Yes, this is the expected behavior but there is no way to get this information from Loguru API.
You'll have to keep a reference of which sinks you added by yourself.