Open CodingKaiser opened 1 month ago
Hi Falko, thank you for opening the issue.
Logging has not been refactored completely yet
INFO
level even though some could be demoted to debugverbose=True
leads to extra output that is printed to standard error which is currently used for command line scripts, maybe (I'm considering it since it would simplify things) we can just send them to loguru.info too.There are the following ways to silence it:
The messages are sent to standard error, so you could capture that (mainly useful for shell scripts so you also have it in case there was an exception)
Use a variation of this snippet:
from loguru import logger
logger.remove()
logger.add(sys.stderr, filter="bfabric", level="WARNING", colorize=False)
logging
module if you prefer that, you just have to give a logging.handler.*" instance to
logger.addinstead of
sys.stderr`. But this is from their docs, they say we should just disable logging in the library and make it opt in for applications
# For libraries, should be your library's `__name__`
logger.disable("my_library")
logger.info("No matter added sinks, this message is not displayed")
# In your application, enable the logger in the library
logger.enable("my_library")
logger.info("This message however is propagated to the sinks")
The only reason I am a bit hesitant to have no logging by default, is that I then expect logging messages to not be available in general. You could also take the logger.disable("bfabric")
approach, if you want no logs at all.
Hi @leoschwarz
I have been using bfabricpy2 for a few weeks now. Awesome work! I was able to get rid of quite some redundant code on my end.
But one question: is there a way to completely silence the loguru logging? I would have expected verbose=False to do the trick, but it seems to only affect messages on top of what loguru already outputs.
Thanks in advance.
All the best, Falko