Using loguru in a library

Roy Hann specially at processed.almost.meat
Sun Apr 30 11:40:21 EDT 2023


Is there anyone using loguru (loguru 0.5.3 in my case) successfully in a
library?


In my __init__.py in mylib I do

  logger.disable('mylib')

which definitely works. I don't get any more logging. 

I "pip install ." the library, then in mytest.py I do

  import mylib
  logger.enable('mylib')

expecting that it would report any log messages above level DEBUG, just
as it does when I don't disable logging. Unfortunately it doesn't
have any effect; it doesn't report any logging from mylib.

I have verified that __name__ is visible in the library and is 'mylib'.

I would also have expected that logger.enable(None) would turn all the
logging on everywhere but it seems not.

I have probably misunderstood how logger.enable() is supposed to be
used. Can anyone share a brief example?

Roy


More information about the Python-list mailing list