From 61c7fd0300f95b91cd2fc61a4385ea0ead970218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sat, 24 Feb 2024 18:41:11 +0100 Subject: [PATCH] Split function send_to_matrix --- appslib/logging_sender.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/appslib/logging_sender.py b/appslib/logging_sender.py index 9cd9c80..4cadf2e 100644 --- a/appslib/logging_sender.py +++ b/appslib/logging_sender.py @@ -6,18 +6,21 @@ import logging import logging.handlers +def send_to_matrix(message: str) -> None: + if which("sendxmpppy") is None: + logging.warning("Could not send error via xmpp.") + return + subprocess.call(["sendxmpppy", message], stdout=subprocess.DEVNULL) + + class LogSenderHandler(logging.Handler): def __init__(self): logging.Handler.__init__(self) self.is_logging = False def emit(self, record): - if which("sendxmpppy") is None: - logging.warning("Could not send error via xmpp.") - return - - msg = f"[Applist builder error] {record.msg}" - subprocess.call(["sendxmpppy", msg], stdout=subprocess.DEVNULL) + msg = f"[Apps tools error] {record.msg}" + send_to_matrix(msg) @classmethod def add(cls, level=logging.ERROR):