[BUG]Passing Console() to RichHandler() interrupts Progress/track when logging #3771
-
Describe the bug Platform Click to expand
Code example import logging
import time
from rich.logging import RichHandler
from rich.progress import track
from rich.console import Console
logger = logging.getLogger(__name__)
logger.setLevel('DEBUG')
# Test the RichHandler with Console()
consolehandler = RichHandler(console=Console())
logger.addHandler(consolehandler)
for n in track(range(5), description="Doing work using Console()"):
logger.info(f"Logging {n} in the middle of progress...")
time.sleep(0.2)
# Test the RichHandler without Console()
logger.removeHandler(consolehandler)
consolehandler = RichHandler()
logger.addHandler(consolehandler)
for n in track(range(5), description="Doing work without using Console()"):
logger.info(f"Logging {n} in the middle of progress...")
time.sleep(0.2) Output
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
We found the following entry in the FAQ which you may find helpful: Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review. This is an automated reply, generated by FAQtory |
Beta Was this translation helpful? Give feedback.
-
You will need to use the same console object for both |
Beta Was this translation helpful? Give feedback.
-
Great, that does it! I love rich, keep up the good work :-) |
Beta Was this translation helpful? Give feedback.
-
As a sidenote, as a user I had expected that track/Progress would just take the console that I had passed to RichHandler. Why isn't that the default behaviour? |
Beta Was this translation helpful? Give feedback.
You will need to use the same console object for both
RichHandler
andtrack
. Both have aconsole
parameter.