diff options
author | Michał Górny <mgorny@gentoo.org> | 2022-09-17 19:01:28 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2022-09-17 19:01:28 +0200 |
commit | 2d198fcb7d58402d629b886e1f2f85206b2fda87 (patch) | |
tree | c70a1f8d40aa031cb1bf8c0a1198eb4e976dbd5b | |
parent | 1d8cdfc64ffba176e181f3602a0443cbcb493d66 (diff) | |
download | gemato-2d198fcb7d58402d629b886e1f2f85206b2fda87.tar.gz |
Support pretty log formatting using rich
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r-- | gemato/cli.py | 19 |
1 files 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)) |