Skip to content

Using logging with rich.progress #1173

Answered by willmcgugan
d-k-bo asked this question in Q&A
Discussion options

You must be logged in to vote

Your example didn't run as is because you didn't set the level on basicConfig, but the following works as expected for me:

import logging
import time

from rich.logging import RichHandler
from rich.progress import Progress

logging.basicConfig(level="NOTSET", handlers=[RichHandler(level="NOTSET")])
logger = logging.getLogger('rich')

with Progress(expand=True) as progress:
    task = progress.add_task("Loading...",)
    while not progress.finished:
        logger.info('some log output')
        progress.update(task, advance=0.1)
        time.sleep(1)

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@d-k-bo
Comment options

Answer selected by d-k-bo
Comment options

You must be logged in to vote
2 replies
@willmcgugan
Comment options

@mezhgano
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants