Skip to content
Snippets Groups Projects
Commit 11f34910 authored by Christoph Schmidt's avatar Christoph Schmidt
Browse files

Fixed logging issues

parent 497a53c0
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ class Form(QDialog): ...@@ -25,7 +25,7 @@ class Form(QDialog):
super().__init__(parent) super().__init__(parent)
child_con = ChildProcessControl3(self, internal_log_level=logging.WARNING, log_file="log.log") child_con = ChildProcessControl3(self, internal_log_level=logging.WARNING, log_file="log.log")
child_con.set_internal_log_level(logging.INFO) #child_con.set_internal_log_level(logging.INFO)
child_con.mp_finished.connect(self.updateUI) child_con.mp_finished.connect(self.updateUI)
...@@ -39,7 +39,7 @@ class Form(QDialog): ...@@ -39,7 +39,7 @@ class Form(QDialog):
self.lineedit.setFocus() self.lineedit.setFocus()
self.setWindowTitle('Upper') self.setWindowTitle('Upper')
# self.lineedit.returnPressed.connect(lambda: child_con.call_without_mp(1, 2, c=3)) # self.lineedit.returnPressed.connect(lambda: child_con.call_without_mp(1, 2, c=3))
self.lineedit.returnPressed.connect(lambda: child_con.exception_call(1)) self.lineedit.returnPressed.connect(lambda: child_con.test_call(1))
def updateUI(self, text): def updateUI(self, text):
......
...@@ -51,7 +51,7 @@ class CBase: ...@@ -51,7 +51,7 @@ class CBase:
if enabled: if enabled:
_internal_logger.disabled = False _internal_logger.disabled = False
_internal_logger.info(f"Logger {logger_name} created with handlers {_internal_logger.handlers} and has been enabled (Level {level}).") _internal_logger.info(f"Logger {logger_name} created with ({len(_internal_logger.handlers)}) handlers and has been enabled (Level {level}).")
else: else:
_internal_logger.info(f"Logger {logger_name} created and has been disabled.") _internal_logger.info(f"Logger {logger_name} created and has been disabled.")
_internal_logger.disabled = True _internal_logger.disabled = True
......
...@@ -66,6 +66,7 @@ class CProcess(CBase, Process): ...@@ -66,6 +66,7 @@ class CProcess(CBase, Process):
f"{os.getpid()}({self.__class__.__name__})", f"{os.getpid()}({self.__class__.__name__})",
logger_handler=logging.handlers.QueueHandler(self.state_queue), logger_handler=logging.handlers.QueueHandler(self.state_queue),
logger_format="%(message)s", logger_format="%(message)s",
enabled=True,
to_file=self.log_file) to_file=self.log_file)
......
...@@ -31,8 +31,9 @@ class CProcessControl(CBase, QObject): ...@@ -31,8 +31,9 @@ class CProcessControl(CBase, QObject):
self.log_file = log_file self.log_file = log_file
self._internal_logger = self.create_new_logger(f"(cmp) {self.name}", self._internal_logger = self.create_new_logger(f"(cmp) {self.name}",
to_file=self.log_file, enabled=internal_log, level=internal_log_level) to_file=self.log_file, enabled=internal_log, level=internal_log_level)
self.logger = self.create_new_logger(f"{self.__class__.__name__}({os.getpid()})", self.logger = self.create_new_logger(f"{self.__class__.__name__}({os.getpid()})",
to_file=self.log_file, enabled=internal_log, level=internal_log_level) to_file=self.log_file, enabled=internal_log)
if isinstance(parent, QWidget) or isinstance(parent, QWindow): if isinstance(parent, QWidget) or isinstance(parent, QWindow):
parent.destroyed.connect(lambda: self.safe_exit(reason="Parent destroyed.")) parent.destroyed.connect(lambda: self.safe_exit(reason="Parent destroyed."))
...@@ -87,7 +88,7 @@ class CProcessControl(CBase, QObject): ...@@ -87,7 +88,7 @@ class CProcessControl(CBase, QObject):
# self._child.register_kill_flag(self._child_kill_flag) # self._child.register_kill_flag(self._child_kill_flag)
self._child_process_pid = child.pid self._child_process_pid = child.pid
self._child.start() self._child.start()
self._internal_logger.debug(f"Child process {self._child.name} created.") self._internal_logger.info(f"Child process {self._child.name} created.")
self.thread_manager.start(self._monitor_result_state) self.thread_manager.start(self._monitor_result_state)
@property @property
......
...@@ -18,11 +18,11 @@ class CResultRecord: ...@@ -18,11 +18,11 @@ class CResultRecord:
logger = logging.getLogger(f"{__name__} - fallback") logger = logging.getLogger(f"{__name__} - fallback")
if self.signal_name is None: if self.signal_name is None:
logger.info(f"Function {self.function_name} returned {self.result}. " logger.debug(f"Function {self.function_name} returned {self.result}. "
f"No signal to emit.") f"No signal to emit.")
return return
if hasattr(class_object, '_internal_logger'): if hasattr(class_object, '_internal_logger'):
logger.info(f"Function {self.function_name} returned {self.result}. " logger.debug(f"Function {self.function_name} returned {self.result}. "
f"Emitting {self} in {class_object.__class__.__name__}.") f"Emitting {self} in {class_object.__class__.__name__}.")
emitter = getattr(class_object, self.signal_name).emit emitter = getattr(class_object, self.signal_name).emit
if isinstance(self.result, tuple): if isinstance(self.result, tuple):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment