From 9879fff33154db0093c6255bb484b6f2621efcd6 Mon Sep 17 00:00:00 2001 From: booksword Date: Thu, 7 Dec 2023 22:19:30 +0800 Subject: [PATCH] fix log --- qlib/log.py | 4 ++-- tests/rl/test_logger.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qlib/log.py b/qlib/log.py index 8140b33748..cdf668c86d 100644 --- a/qlib/log.py +++ b/qlib/log.py @@ -35,13 +35,13 @@ def __init__(self, module_name): # However, due to bug in pytest, it requires log message to propagate to root logger to be captured by `caplog` [2]. # [1] https://github.com/microsoft/qlib/pull/1661 # [2] https://github.com/pytest-dev/pytest/issues/3697 - self.propagate = False + self.parent_propagate = False @property def logger(self): logger = logging.getLogger(self.module_name) logger.setLevel(self.__level) - logger.parent.propagate = self.propagate + logger.parent.propagate = self.parent_propagate return logger def setLevel(self, level): diff --git a/tests/rl/test_logger.py b/tests/rl/test_logger.py index 156cb98ca5..3fdfbb8f86 100644 --- a/tests/rl/test_logger.py +++ b/tests/rl/test_logger.py @@ -69,7 +69,7 @@ def learn(self, batch): def test_simple_env_logger(caplog): set_log_with_config(C.logging_config) writer = ConsoleWriter() - writer.console_logger.propagate = True + writer.console_logger.parent_propagate = True for venv_cls_name in ["dummy", "shmem", "subproc"]: csv_writer = CsvWriter(Path(__file__).parent / ".output") venv = vectorize_env(lambda: SimpleEnv(), venv_cls_name, 4, [writer, csv_writer])