diff --git a/labgrid/logging.py b/labgrid/logging.py index a3807ecf1..215f0f8f8 100644 --- a/labgrid/logging.py +++ b/labgrid/logging.py @@ -127,7 +127,7 @@ def flush(self): class StepLogger: - _started = False + started = False _logger = None _serial_logger = None _length_limit = 100 @@ -144,21 +144,21 @@ def __attrs_post_init__(self): @classmethod def start(cls, length_limit=None): """starts the StepLogger""" - assert not cls._started + assert not cls.started if cls._logger is None: cls._logger = logging.getLogger("StepLogger") steps.subscribe(cls.notify) cls._serial_logger = SerialLoggingReporter() - cls._started = True + cls.started = True if length_limit is not None: cls._length_limit = length_limit @classmethod def stop(cls): """stops the StepLogger""" - assert cls._started + assert cls.started steps.unsubscribe(cls.notify) - cls._started = False + cls.started = False @classmethod def get_prefix(cls, event): diff --git a/labgrid/pytestplugin/hooks.py b/labgrid/pytestplugin/hooks.py index a701e5ccb..84a1924ae 100644 --- a/labgrid/pytestplugin/hooks.py +++ b/labgrid/pytestplugin/hooks.py @@ -62,8 +62,9 @@ def configure_pytest_logging(config, plugin): @pytest.hookimpl(trylast=True) def pytest_configure(config): - StepLogger.start() - config.add_cleanup(StepLogger.stop) + if not StepLogger.started: + StepLogger.start() + config.add_cleanup(StepLogger.stop) logging_plugin = config.pluginmanager.getplugin('logging-plugin') if logging_plugin: