Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16506

How to suppress logging.warning from imported module (which uses loguru)

$
0
0

I am using a function from an imported module within an optimization loop. As a consequence the function gets called 10s or 100s of times. Since this is an optimization, sometimes the test parameters will cause a warning to be raised in the function being called (for example, because they are below a threshold value). I'm ok with these warnings, but I don't need them to appear 100s of times in my terminal. I am fine with manually checking the resulting parameters after the optimization has completed.

Is there some kind context manager that can be used to suppress any calls to logger.warning just for this function call?

An extra wrinkle is that the imported module is using loguru for logging. I'm not sure if that necessitates a different solution or not.


Viewing all articles
Browse latest Browse all 16506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>