I’m trying to make some action whenever an exception occurs using the function
listen_log
Let’s pretend the code is:
def initialize(self):
self.listen_log(self.log_function, "WARNING")
def log_function(self, level, log, pin, pin_thread, num, kwargs):
self.call_service(service ='persistent_notification/create', title = "ERROR", message = "notification")
The function actually works for some logs: I mispelled a service inside other functions and this is the log:
2021-09-23 11:39:01.015110 WARNING AppDaemon: Unknown domain (default/imaginary_service) in call_service from change
and my function log_function is called. But for other bugs (the ones i’m really interested about) this is the log:
2021-09-23 11:50:48.712234 WARNING change: Worker Ags: [other stuff]
[other stuff]
IndexError: list index out of range
It probably has to do with ‘WARNING change’ and ‘WARNING AppDaemon’. How do I solve it in order to call my function?