catch permission exception if logfile not writable

This commit is contained in:
Robert Kaussow 2019-12-19 10:25:04 +01:00
parent 34bab35b34
commit 5d17b31750

View File

@ -73,7 +73,14 @@ class Log:
self.logger.addHandler(self._get_info_handler(json=json)) self.logger.addHandler(self._get_info_handler(json=json))
self.logger.addHandler(self._get_critical_handler(json=json)) self.logger.addHandler(self._get_critical_handler(json=json))
self.logger.addHandler(self._get_debug_handler(json=json)) self.logger.addHandler(self._get_debug_handler(json=json))
self.logger.addHandler(self._get_file_handler(logfile=logfile, json=json))
try:
self.logger.addHandler(self._get_file_handler(logfile=logfile, json=json))
except PermissionError as e:
if e.errno == 13:
self.logger.warning("Can't write to logfile\n{}: '{}'".format(e.strerror, e.filename))
pass
self.logger.propagate = False self.logger.propagate = False
def _get_file_handler(self, logfile, json=False): def _get_file_handler(self, logfile, json=False):