mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-25 08:28:23 +01:00
fix notify on error
This commit is contained in:
parent
9f655c9393
commit
cde20f647d
2 changed files with 16 additions and 15 deletions
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.0.7.rc2"
|
__version__ = "4.0.7.rc3"
|
||||||
__codename__ = "November Rain"
|
__codename__ = "November Rain"
|
||||||
|
|
||||||
|
|
|
@ -12,24 +12,25 @@ class NotificationController:
|
||||||
'''
|
'''
|
||||||
self.cbpi = cbpi
|
self.cbpi = cbpi
|
||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
NOTIFY_ON_ERROR = self.cbpi.config.get("NOTIFY_ON_ERROR", "No")
|
logging.root.addFilter(self.notify_log_event)
|
||||||
if NOTIFY_ON_ERROR == "Yes":
|
|
||||||
logging.root.addFilter(self.notify_log_event)
|
|
||||||
self.callback_cache = {}
|
self.callback_cache = {}
|
||||||
self.listener = {}
|
self.listener = {}
|
||||||
|
|
||||||
def notify_log_event(self, record):
|
def notify_log_event(self, record):
|
||||||
try:
|
NOTIFY_ON_ERROR = self.cbpi.config.get("NOTIFY_ON_ERROR", "No")
|
||||||
if record.levelno > 20:
|
if NOTIFY_ON_ERROR == "Yes":
|
||||||
# on log events higher then INFO we want to notify all clients
|
try:
|
||||||
type = NotificationType.WARNING
|
if record.levelno > 20:
|
||||||
if record.levelno > 30:
|
# on log events higher then INFO we want to notify all clients
|
||||||
type = NotificationType.ERROR
|
type = NotificationType.WARNING
|
||||||
self.cbpi.notify(title=f"{record.levelname}", message=record.msg, type = type)
|
if record.levelno > 30:
|
||||||
except Exception as e:
|
type = NotificationType.ERROR
|
||||||
pass
|
self.cbpi.notify(title=f"{record.levelname}", message=record.msg, type = type)
|
||||||
finally:
|
except Exception as e:
|
||||||
return True
|
pass
|
||||||
|
finally:
|
||||||
|
return True
|
||||||
|
return True
|
||||||
|
|
||||||
def add_listener(self, method):
|
def add_listener(self, method):
|
||||||
listener_id = shortuuid.uuid()
|
listener_id = shortuuid.uuid()
|
||||||
|
|
Loading…
Reference in a new issue