Split function send_to_matrix
This commit is contained in:
parent
1b39a34a4c
commit
61c7fd0300
1 changed files with 9 additions and 6 deletions
|
@ -6,18 +6,21 @@ import logging
|
||||||
import logging.handlers
|
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):
|
class LogSenderHandler(logging.Handler):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
logging.Handler.__init__(self)
|
logging.Handler.__init__(self)
|
||||||
self.is_logging = False
|
self.is_logging = False
|
||||||
|
|
||||||
def emit(self, record):
|
def emit(self, record):
|
||||||
if which("sendxmpppy") is None:
|
msg = f"[Apps tools error] {record.msg}"
|
||||||
logging.warning("Could not send error via xmpp.")
|
send_to_matrix(msg)
|
||||||
return
|
|
||||||
|
|
||||||
msg = f"[Applist builder error] {record.msg}"
|
|
||||||
subprocess.call(["sendxmpppy", msg], stdout=subprocess.DEVNULL)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add(cls, level=logging.ERROR):
|
def add(cls, level=logging.ERROR):
|
||||||
|
|
Loading…
Reference in a new issue