diff options
| author | Juraj Linkeš <[email protected]> | 2024-03-01 11:55:21 +0100 |
|---|---|---|
| committer | Thomas Monjalon <[email protected]> | 2024-03-07 15:54:10 +0100 |
| commit | 04f5a5a6e48a06d86ccc5236452514bfbb0b6de7 (patch) | |
| tree | eedf9b69eac2e133b3ee1e1f5c014dcf83b78e06 /dts/framework/testbed_model/node.py | |
| parent | caae1889ea1dab24fa582deadcf2884bdcc1aa89 (diff) | |
dts: refactor logging configuration
Remove unused parts of the code and add useful features:
1. Add DTS execution stages such as execution and test suite to better
identify where in the DTS lifecycle we are when investigating logs,
2. Logging to separate files in specific stages, which is mainly useful
for having test suite logs in additional separate files.
3. Remove the dependence on the settings module which enhances the
usefulness of the logger module, as it can now be imported in more
modules.
The execution stages and the files to log to are the same for all DTS
loggers. To achieve this, we have one DTS root logger which should be
used for handling stage switching and all other loggers are children of
this DTS root logger. The DTS root logger is the one where we change the
behavior of all loggers (the stage and which files to log to) and the
child loggers just log messages under a different name.
Signed-off-by: Juraj Linkeš <[email protected]>
Reviewed-by: Jeremy Spewock <[email protected]>
Diffstat (limited to 'dts/framework/testbed_model/node.py')
| -rw-r--r-- | dts/framework/testbed_model/node.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/dts/framework/testbed_model/node.py b/dts/framework/testbed_model/node.py index 1a55fadf78..74061f6262 100644 --- a/dts/framework/testbed_model/node.py +++ b/dts/framework/testbed_model/node.py @@ -23,7 +23,7 @@ from framework.config import ( NodeConfiguration, ) from framework.exception import ConfigurationError -from framework.logger import DTSLOG, getLogger +from framework.logger import DTSLogger, get_dts_logger from framework.settings import SETTINGS from .cpu import ( @@ -63,7 +63,7 @@ class Node(ABC): name: str lcores: list[LogicalCore] ports: list[Port] - _logger: DTSLOG + _logger: DTSLogger _other_sessions: list[OSSession] _execution_config: ExecutionConfiguration virtual_devices: list[VirtualDevice] @@ -82,7 +82,7 @@ class Node(ABC): """ self.config = node_config self.name = node_config.name - self._logger = getLogger(self.name) + self._logger = get_dts_logger(self.name) self.main_session = create_session(self.config, self.name, self._logger) self._logger.info(f"Connected to node: {self.name}") @@ -189,7 +189,7 @@ class Node(ABC): connection = create_session( self.config, session_name, - getLogger(session_name, node=self.name), + get_dts_logger(session_name), ) self._other_sessions.append(connection) return connection @@ -299,7 +299,6 @@ class Node(ABC): self.main_session.close() for session in self._other_sessions: session.close() - self._logger.logger_exit() @staticmethod def skip_setup(func: Callable[..., Any]) -> Callable[..., Any]: @@ -314,7 +313,7 @@ class Node(ABC): return func -def create_session(node_config: NodeConfiguration, name: str, logger: DTSLOG) -> OSSession: +def create_session(node_config: NodeConfiguration, name: str, logger: DTSLogger) -> OSSession: """Factory for OS-aware sessions. Args: |
