Delgan / loguru

Python logging made (stupidly) simple
MIT License
18.69k stars 682 forks source link

Loguru suppresses an instance of logger from `logging.getLogger()` #1141

Closed Adversarian closed 1 month ago

Adversarian commented 1 month ago

Hi, I would to begin by thanking you for the amount of work you've put into making me not want to paint the walls in red whenever I decide to perform any form of logging this tremendous library.

I've recently encountered an issue which I'm sure is happening by design and the answer to which I have unfortunately not been able to find in the past issues.

I'm currently using a library (sentence-transformers if it's of any consequence), which happens to be using the default logger from logging library. In a script where I'm making use of this library I'm also logging my own events which is handled by loguru. However, it appears that whenever an event is logged in the external library (see this file for reference), the log is suppressed by loguru and nothing is actually written to stdout.

Is there anyway I can circumvent this without having to alter the external library?

Thanks in advance!

Delgan commented 1 month ago

Hey @Adversarian.

Did you try to setup an InterceptHandler as explained here: Entirely compatible with standard logging?

Adversarian commented 1 month ago

That would be exactly what I need. Thank you so much @Delgan!

Delgan commented 1 month ago

You're welcome, glad you like Loguru. :+1: