Skip to content

Commit

Permalink
Merge pull request #1340 from samson0v/master
Browse files Browse the repository at this point in the history
Fixed stopping remote logging
  • Loading branch information
imbeacon committed Mar 19, 2024
2 parents 8c3d84f + 095acc2 commit a280797
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,6 @@ def _handle_logs_configuration_update(self, config):
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=' '))
Expand Down
5 changes: 3 additions & 2 deletions thingsboard_gateway/tb_utility/tb_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def activate(self, log_level=None):
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:
Expand All @@ -121,6 +121,7 @@ def handle(self, record):

def deactivate(self):
self.activated = False
self._send_logs_thread.join()

@staticmethod
def set_default_handler():
Expand Down

0 comments on commit a280797

Please sign in to comment.