From 46d2f306e2b08ed393b7d302f09ea492187a734e Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sun, 27 Jul 2025 14:58:42 +0200 Subject: [PATCH] Adaption to app logging method --- config.py | 11 +++++++++-- mqtt | 2 +- mqtt_sniffer.py | 9 +++------ report | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/config.py b/config.py index 127968a..d05b63b 100644 --- a/config.py +++ b/config.py @@ -1,3 +1,10 @@ -APP_NAME = 'mqtt_sniffer' +import logging + + +DEBUG = True +# +# Logging +# +APP_NAME = 'mqtt_sniffer' +LOG_HOSTNAME = "loggy" # When DEBUG is True -DEBUG = False \ No newline at end of file diff --git a/mqtt b/mqtt index 328d347..14e56cc 160000 --- a/mqtt +++ b/mqtt @@ -1 +1 @@ -Subproject commit 328d3471a748472695a61193becdda76c7eefe69 +Subproject commit 14e56ccdbf6594f699b4afcfb4acafe9b899e914 diff --git a/mqtt_sniffer.py b/mqtt_sniffer.py index 2de76e1..bf5a433 100644 --- a/mqtt_sniffer.py +++ b/mqtt_sniffer.py @@ -13,11 +13,8 @@ from textual.widgets import Footer, Header, Input, RichLog, Button, Select, Chec from mytui import MultiSelect -try: - from config import APP_NAME as ROOT_LOGGER_NAME -except ImportError: - ROOT_LOGGER_NAME = 'root' -logger = logging.getLogger(ROOT_LOGGER_NAME) +logger = report.app_logging_config() + filename = os.path.splitext(__file__)[0] + '.log' filelogger = logging.getLogger('filelogger') @@ -39,7 +36,7 @@ class MqttHandler(object): self.mqtt_client.add_callback("#", self.__rx__) def __get_logger__(self, prefix, topic): - return logging.getLogger(ROOT_LOGGER_NAME).getChild(prefix + '.' + topic.replace('/', '.')) + return logger.getChild(prefix + '.' + topic.replace('/', '.')) def __rx__(self, client, userdata, message): logger = self.__get_logger__('rx', message.topic) diff --git a/report b/report index 3b8fbbc..a10d793 160000 --- a/report +++ b/report @@ -1 +1 @@ -Subproject commit 3b8fbbc0844d17377b3d5da84bca8cad6d24d143 +Subproject commit a10d79357e4fba89e753e61cb703560c76824ae5