Skip to content
Discussion options

You must be logged in to vote

My final solution below. Thank you @jdfesa for the app.add_alert, it works great for my situation. Also thanks @Erfouni , I like having options, especially when they require less typing. I'll whip that one out when I'm not using Progress.

class MyCmd(Cmd):

    # Unchanged

    def do_hello(self, _):
        with Progress() as progress:
            progress.add_task("[cyan]Working...", total=None)
            logger.warning("Hello world!")
            time.sleep(2)
            logger.warning("Hello world!")


class CmdHandler(RichHandler):
    app: MyCmd | None = None

    def _get_renderable(self, record: logging.LogRecord) -> ConsoleRenderable:
        """Copied from `RichHandler.emit` …

Replies: 3 comments 3 replies

Comment options

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

@ShiftPoster
Comment options

Answer selected by ShiftPoster
Comment options

You must be logged in to vote
1 reply
@ShiftPoster
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants