more logging

This commit is contained in:
Franzi 2024-07-30 18:42:29 +02:00
parent 778cefa9b1
commit d3124ac846
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -50,7 +50,7 @@ TABLE_LAYOUT = {
}, },
} }
# logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
mqtt_data = {} mqtt_data = {}
@ -59,6 +59,7 @@ mqtt_data = {}
def on_connect(client, userdata, flags, rc): def on_connect(client, userdata, flags, rc):
LOG.info(f"Connected to mqtt server") LOG.info(f"Connected to mqtt server")
mqtt.subscribe(MQTT_SUB) mqtt.subscribe(MQTT_SUB)
LOG.info(f"subscribing to {MQTT_SUB}")
def on_disconnect(client, userdata, rc): def on_disconnect(client, userdata, rc):
@ -102,16 +103,20 @@ def generate_layout():
try: try:
LOG.info('mooooin!')
mqtt = mqtt.Client() mqtt = mqtt.Client()
mqtt.on_connect = on_connect mqtt.on_connect = on_connect
mqtt.on_disconnect = on_disconnect mqtt.on_disconnect = on_disconnect
mqtt.on_message = on_message mqtt.on_message = on_message
mqtt.connect(config["mqtt"]["host"], config["mqtt"]["port"], 10) mqtt.connect(config["mqtt"]["host"], config["mqtt"]["port"], 10)
mqtt.loop_start()
LOG.info('starting loop')
mqtt.loop_start()
with Live(generate_layout(), screen=True) as live: with Live(generate_layout(), screen=True) as live:
while True: while True:
live.update(generate_layout()) live.update(generate_layout())
sleep(0.5) sleep(0.5)
mqtt.loop_stop()
LOG.info('bye')
except Exception: except Exception:
LOG.exception("oops") LOG.exception("oops")