From 834ea75fd864a359cf271aed1885cc9c07f412f6 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Tue, 29 Mar 2022 19:28:20 +0200 Subject: [PATCH] Add logging --- its_matrix_bot/__init__.py | 6 +++++- its_matrix_bot/__main__.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/its_matrix_bot/__init__.py b/its_matrix_bot/__init__.py index 28610f8..4ba44cc 100755 --- a/its_matrix_bot/__init__.py +++ b/its_matrix_bot/__init__.py @@ -1,5 +1,6 @@ import asyncio import datetime +import logging from nio.rooms import MatrixRoom from nio.events.room_events import RoomMessage import simplematrixbotlib as botlib @@ -35,6 +36,7 @@ class ItSyndikatBot: async def run(self): async def poll_for_changes(): while True: + logging.debug("Polling open state") try: status = await self.its_api.status() new_state = status["state"]["open"] @@ -45,7 +47,7 @@ class ItSyndikatBot: await self.announce_open_change(new_state) self.current_open_state = new_state except Exception as e: - pass + logging.error(f"Polling for open state failed: {e}") await asyncio.sleep(60) @@ -69,6 +71,8 @@ class ItSyndikatBot: ) async def announce_open_change(self, now_open: bool): + logging.info("Open state changed: now " + ("open" if now_open else "closed")) + room_ids = self.config.isitopen_announce_rooms if now_open: message = "opening IT-Syndikat - Ohai!" diff --git a/its_matrix_bot/__main__.py b/its_matrix_bot/__main__.py index 7dea5ae..c5c744c 100644 --- a/its_matrix_bot/__main__.py +++ b/its_matrix_bot/__main__.py @@ -1,9 +1,12 @@ import asyncio import argparse +import logging from . import ItSyndikatBot from .config import Config +logging.basicConfig(level=logging.DEBUG) + parser = argparse.ArgumentParser(description="IT-Syndikat matrix bot") parser.add_argument( "-c",