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?
On 2023-04-30 16:40, Roy Hann wrote:
Is there anyone using loguru (loguru 0.5.3 in my case) successfully in aAccording to the docs, the argument is the name of the module.
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?
In your example, the name of the module (i.e. file) is "__init__";
"mylib" is the name of the package.
Is there anyone using loguru (loguru 0.5.3 in my case) successfully in a >library?
...
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.
Roy Hann wrote at 2023-4-30 15:40 -0000:
Is there anyone using loguru (loguru 0.5.3 in my case) successfully in a >>library?
...
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.
Have you configured the logging system?
Note that `logging.config.fileConfig` may do strange things
regarding disabling (due to its default parameter `disable_existing_loggers=True`).
I had several cases of missing log entries because `fileConfig`
had disabled already existing loggers.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 76:18:18 |
Calls: | 6,716 |
Calls today: | 4 |
Files: | 12,247 |
Messages: | 5,357,561 |