1
0
mirror of https://github.com/thingsboard/thingsboard-gateway synced 2025-10-26 22:31:42 +08:00

Fixed stopping remote logging

This commit is contained in:
samson0v
2024-03-19 13:25:26 +02:00
parent 8c3d84f9ce
commit 095acc260d
2 changed files with 3 additions and 7 deletions

View File

@@ -403,11 +403,6 @@ class RemoteConfigurator:
config['loggers'][logger]['handlers'].remove(handler)
config['handlers'] = target_handlers
dictConfig(config)
LOG = getLogger('service')
self._gateway.remote_handler = TBLoggerHandler(self._gateway)
self._gateway.remote_handler.activate(self._gateway.main_handler.level)
self._gateway.main_handler.setTarget(self._gateway.remote_handler)
LOG.addHandler(self._gateway.remote_handler)
with open(logs_conf_file_path, 'w') as logs:
logs.write(dumps(config, indent=' '))

View File

@@ -105,8 +105,8 @@ class TBLoggerHandler(logging.Handler):
log = TbLogger('service')
log.exception(e)
self.activated = True
if not self._send_logs_thread.is_alive():
self._send_logs_thread.start()
self._send_logs_thread = threading.Thread(target=self._send_logs, name='Logs Sending Thread', daemon=True)
self._send_logs_thread.start()
def handle(self, record):
if self.activated and not self.__gateway.stopped:
@@ -121,6 +121,7 @@ class TBLoggerHandler(logging.Handler):
def deactivate(self):
self.activated = False
self._send_logs_thread.join()
@staticmethod
def set_default_handler():