Improved logging and error handling for mcm
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user