rich icon indicating copy to clipboard operation
rich copied to clipboard

What is the correct way to log error messages with a Progress Bar Console?

Open mikegrima opened this issue 3 years ago • 0 comments

Hello!

I'm trying to figure out what the right way is to log to stderr when using a progress bar for select items only. I wasn't able to find docs or good examples of this. Here is the use case:

  • I have a thread that does some processing
  • The thread will output to the log whenever it's doing some work
  • When there is an error, the thread should output to stderr that there is a problem
  • The progress bar should continue working properly and be rendered at the bottom of the screen

Per the docs for the Console API, for the error console (https://rich.readthedocs.io/en/latest/console.html#error-console), it is recommended that you make 2 consoles, one for stdout, and one for stderr. When defining the Progress() bar object, you can pass in a Console object via the console= keyword argument. However, this is only for 1 console. If I had 2 consoles, one for stdout, and one for stderr, how would I output to stderr without messing up the progress bar on screen?

mikegrima avatar Jun 28 '22 17:06 mikegrima