The output is all messed up when using custom logging handlers.
Here is a minimal example:
from alive_progress import alive_bar
from time import sleep
import logging
my_logger = logging.getLogger("my_logger")
my_handler = logging.StreamHandler()
my_logger.addHandler(my_handler) # no logger output without this line
my_logger.setLevel(logging.INFO)
with alive_bar(5) as bar:
for x in range(5):
sleep(0.1)
my_logger.info(f"!!!At step {x} / 5")
bar()
The following code works but I can't refactor my code this way because I use librairies that also use logging and setting the global level just clutters my output...
from alive_progress import alive_bar
from time import sleep
import logging
logging.basicConfig(level=logging.INFO)
my_logger = logging.getLogger("my_logger")
# my_handler = logging.StreamHandler()
# my_logger.addHandler(my_handler)
# my_logger.setLevel(logging.INFO)
with alive_bar(5) as bar:
for x in range(5):
sleep(0.1)
my_logger.info(f"!!!At step {x} / 5")
bar()
I'm not sure if you can auto-detect custom handlers. If not I'm fine with registering them with something like
from alive_progress import add_logger_hook
...
add_logger_hook(my_logger) # like this
add_logger_hook(my_handler) # or this
Specs:
python version 3.9.7
alive-progress version 2.3.1
Terminal: konsole 21.08.1
OS: Kubuntu 21.10 x86_64
Kernel: 5.13.0-30-generic
Shell: bash 5.1.8
DE: Plasma 5.22.5
WM: KWin
The output is all messed up when using custom logging handlers. Here is a minimal example:
Which gives the following output
While the desired output would be:
The following code works but I can't refactor my code this way because I use librairies that also use
logging
and setting the global level just clutters my output...I'm not sure if you can auto-detect custom handlers. If not I'm fine with registering them with something like
Specs: python version 3.9.7 alive-progress version 2.3.1 Terminal: konsole 21.08.1 OS: Kubuntu 21.10 x86_64 Kernel: 5.13.0-30-generic Shell: bash 5.1.8 DE: Plasma 5.22.5 WM: KWin