summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2022-09-17 19:01:28 +0200
committerMichał Górny <mgorny@gentoo.org>2022-09-17 19:01:28 +0200
commit2d198fcb7d58402d629b886e1f2f85206b2fda87 (patch)
treec70a1f8d40aa031cb1bf8c0a1198eb4e976dbd5b
parent1d8cdfc64ffba176e181f3602a0443cbcb493d66 (diff)
downloadgemato-2d198fcb7d58402d629b886e1f2f85206b2fda87.tar.gz
Support pretty log formatting using rich
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--gemato/cli.py19
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))