Skip to content

Commit

Permalink
fix log
Browse files Browse the repository at this point in the history
  • Loading branch information
qianyun210603 committed Dec 8, 2023
1 parent 532b1a4 commit 9879fff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions qlib/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/rl/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 9879fff

Please sign in to comment.