From 2d198fcb7d58402d629b886e1f2f85206b2fda87 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Sat, 17 Sep 2022 19:01:28 +0200 Subject: Support pretty log formatting using rich MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- gemato/cli.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/gemato/cli.py b/gemato/cli.py index 4df8ee7..382e961 100644 --- a/gemato/cli.py +++ b/gemato/cli.py @@ -659,8 +659,21 @@ def main(argv): def setuptools_main(): + try: + from rich.logging import RichHandler + except ImportError: + format_args = { + "format": "[{levelname:>7}] {message}", + "style": "{", + } + else: + format_args = { + "format": "{message}", + "style": "{", + "handlers": [RichHandler(show_time=False, show_path=False)], + } + logging.basicConfig( - format="[{levelname:>7}] {message}", - style="{", - level=logging.INFO) + level=logging.INFO, + **format_args) sys.exit(main(sys.argv)) -- cgit v1.2.3