Automatically remove the default sink
I would like each library to remove the default sink when adding its own logger configuration, to prevent duplicate log output.
Otherwise, in the main project, you would need to call logger.remove() before importing any libraries that use loguru.
from loguru import logger
logger.remove()
import module1_with_loguru
import module2_with_loguru
...
Hi.
Normally, libraries are not supposed to configure the logger. Handlers should be added exclusively by the end-user, precisely to avoid conflicts and duplication.
In your example, these module1_with_loguru and module2_with_loguru can use the logger instance to emit messages. However, they should not have any expectations about the configured handlers, and should not call logger.add() unconditionally. That should be done only once by the entry point of your application.
Note that it's possible to "automatically remove the default sink" by setting the LOGURU_AUTOINIT environment variable to "0", but that's probably not what you really need.