fix notify on error

This commit is contained in:
avollkopf 2022-12-02 20:25:27 +01:00
parent 9f655c9393
commit cde20f647d
2 changed files with 16 additions and 15 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.0.7.rc2"
__version__ = "4.0.7.rc3"
__codename__ = "November Rain"

View file

@ -12,13 +12,13 @@ class NotificationController:
'''
self.cbpi = cbpi
self.logger = logging.getLogger(__name__)
NOTIFY_ON_ERROR = self.cbpi.config.get("NOTIFY_ON_ERROR", "No")
if NOTIFY_ON_ERROR == "Yes":
logging.root.addFilter(self.notify_log_event)
self.callback_cache = {}
self.listener = {}
def notify_log_event(self, record):
NOTIFY_ON_ERROR = self.cbpi.config.get("NOTIFY_ON_ERROR", "No")
if NOTIFY_ON_ERROR == "Yes":
try:
if record.levelno > 20:
# on log events higher then INFO we want to notify all clients
@ -30,6 +30,7 @@ class NotificationController:
pass
finally:
return True
return True
def add_listener(self, method):
listener_id = shortuuid.uuid()