1
0
Fork 0

Split function send_to_matrix

This commit is contained in:
Félix Piédallu 2024-02-24 18:41:11 +01:00
parent 1b39a34a4c
commit 61c7fd0300

View file

@ -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):