Skip to content

Commit

Permalink
Fix duplicate logging
Browse files Browse the repository at this point in the history
Currently check `handler is WatchedFileHandler` always fails and a new handler is added every time _setup_logger is called.

For example corrector logs every line three times.

A fix for opendata was added with pull request #14

This commit makes the same change in all the other services.
  • Loading branch information
VitaliStupin authored and melbeltagy committed May 20, 2024
1 parent 3a826e2 commit 9f0c807
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion analysis_module/opmon_analyzer/logger_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _create_file_handler(self):

def _handler_is_set(self, handlers):
for handler in handlers:
if handler is WatchedFileHandler and os.path.abspath(self.log_path) == handler.baseFilename:
if isinstance(handler, WatchedFileHandler) and os.path.abspath(self.log_path) == handler.baseFilename:
return True
return False

Expand Down
2 changes: 1 addition & 1 deletion analysis_ui_module/opmon_analyzer_ui/logger_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _create_file_handler(self):

def _handler_is_set(self, handlers):
for handler in handlers:
if handler is WatchedFileHandler and os.path.abspath(self.log_path) == handler.baseFilename:
if isinstance(handler, WatchedFileHandler) and os.path.abspath(self.log_path) == handler.baseFilename:
return True
return False

Expand Down
2 changes: 1 addition & 1 deletion anonymizer_module/opmon_anonymizer/utils/logger_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _create_file_handler(self):

def _handler_is_set(self, handlers):
for handler in handlers:
if handler is WatchedFileHandler and os.path.abspath(self.log_path) == handler.baseFilename:
if isinstance(handler, WatchedFileHandler) and os.path.abspath(self.log_path) == handler.baseFilename:
return True
return False

Expand Down
2 changes: 1 addition & 1 deletion collector_module/opmon_collector/logger_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _create_file_handler(self):

def _handler_is_set(self, handlers):
for handler in handlers:
if handler is WatchedFileHandler and os.path.abspath(self.log_path) == handler.baseFilename:
if isinstance(handler, WatchedFileHandler) and os.path.abspath(self.log_path) == handler.baseFilename:
return True
return False

Expand Down
2 changes: 1 addition & 1 deletion corrector_module/opmon_corrector/logger_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _create_file_handler(self):

def _handler_is_set(self, handlers):
for handler in handlers:
if handler is WatchedFileHandler and os.path.abspath(self.log_path) == handler.baseFilename:
if isinstance(handler, WatchedFileHandler) and os.path.abspath(self.log_path) == handler.baseFilename:
return True
return False

Expand Down
2 changes: 1 addition & 1 deletion reports_module/opmon_reports/logger_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _create_file_handler(self):

def _handler_is_set(self, handlers):
for handler in handlers:
if handler is WatchedFileHandler and os.path.abspath(self.log_path) == handler.baseFilename:
if isinstance(handler, WatchedFileHandler) and os.path.abspath(self.log_path) == handler.baseFilename:
return True
return False

Expand Down

0 comments on commit 9f0c807

Please sign in to comment.