setup rich logging handler

This commit is contained in:
Laureηt 2023-05-24 21:46:42 +02:00
parent 2893239bb3
commit aa6e8e79c2
Signed by: Laurent
SSH key fingerprint: SHA256:kZEpW8cMJ54PDeCvOhzreNr4FSh6R13CMGH/POoO8DI

View file

@ -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")