How to use the rich.logging function in rich

To help you get started, we’ve selected a few rich examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nf-core / tools / nf_core / __main__.py View on Github external
def nf_core_cli(verbose):
    stderr = rich.console.Console(file=sys.stderr)
    logging.basicConfig(
        level=logging.DEBUG if verbose else logging.INFO,
        format="%(message)s",
        datefmt=".",
        handlers=[rich.logging.RichHandler(console=stderr)],
    )
github riga / law / law / contrib / rich / logging.py View on Github external
if any(multi_match(name, scope) for scope in scopes):
            if getattr(logger, "handlers", None) is not None:
                level = logger.level
                replace_handler = False
                for hdlr in logger.handlers:
                    if isinstance(hdlr, logging.StreamHandler) and hdlr.stream.isatty():
                        if getattr(hdlr, "level", None) is not None:
                            level = hdlr.level

                        # remove old handler
                        logger.removeHandler(hdlr)
                        replace_handler = True

                if replace_handler:
                    # create and add new handler
                    new_hdlr = rich_logging.RichHandler(level)
                    logger.addHandler(new_hdlr)