Improved logging and error handling for mcm
build-and-push / check-branch (push) Successful in 14s
build-and-push / prepare (push) Successful in 10s
build-and-push / build (amd64, linux/amd64) (push) Successful in 1m38s

This commit is contained in:
2026-10-11 17:21:34 +03:30
parent 03cd5ee028
commit f53f2f6309
4 changed files with 61 additions and 3 deletions
+11
View File
@@ -3,6 +3,7 @@ import datetime
import json
import logging
import os
import sys
import time
from flask import Flask, jsonify, render_template, request
@@ -14,6 +15,16 @@ from mqtt_worker import MqttWorker
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(name)s %(message)s")
log = logging.getLogger("main")
def _log_uncaught(exc_type, exc, tb):
# Python prints uncaught exceptions straight to stderr, bypassing
# logging entirely -- which is why a crash traceback had no timestamp
# while every other line did. Route it through the logger instead.
log.critical("uncaught exception, add-on is exiting", exc_info=(exc_type, exc, tb))
sys.excepthook = _log_uncaught
OPTIONS_PATH = "/data/options.json"
SSL_DIR = "/ssl"
BROKER_CERT_FILENAME = "mosquitto-server.crt"