From aa6e8e79c29849a75475a3fdb8f7b0d52eca63a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Wed, 24 May 2023 21:46:42 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20setup=20rich=20logging=20handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nio-llm/client.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/nio-llm/client.py b/nio-llm/client.py index ea8ec4d..be1b447 100644 --- a/nio-llm/client.py +++ b/nio-llm/client.py @@ -9,6 +9,7 @@ import click from huggingface_hub import hf_hub_download from llama_cpp import Llama from nio import AsyncClient, MatrixRoom, RoomMessageText +from rich.logging import RichHandler logger = logging.getLogger("nio-llm") @@ -188,10 +189,10 @@ async def _main( ) # Login to the homeserver - print(await client.login(password)) + logger.debug(await client.login(password)) # Join the room, if not already joined - print(await client.join(room)) + logger.debug(await client.join(room)) # Sync with the server forever await client.sync_forever(timeout=30000) @@ -199,7 +200,12 @@ async def _main( if __name__ == "__main__": # set up logging - logging.basicConfig(level=logging.DEBUG) + logging.captureWarnings(True) + logging.basicConfig( + level="DEBUG", + format="%(name)s: %(message)s", + handlers=[RichHandler(markup=True)], + ) # run the main program (with environment variables) main(auto_envvar_prefix="NIOLLM")