Skip to content

Commit a9738bf

Browse files
authored
Fix duplicated log of jobs (#153)
Now the Python logger used to report the spawned jobs is now registered with only one stream handler to the standard output. Before this change, every tool class was registering a stream handler to the logger, to the messages were written to standard output more than once.
1 parent a25efcf commit a9738bf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cpp/lib.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,9 @@ def __init__(self, config: dict, user_config: dict):
466466
self._config = config
467467
self._user_config = user_config
468468

469-
@cached_property
470-
def job_logger(self) -> logging.Logger:
469+
@staticmethod
470+
@functools.lru_cache()
471+
def job_logger() -> logging.Logger:
471472
"""
472473
Return:
473474
`logging.getLogger` instance use to report
@@ -694,7 +695,7 @@ def _run_chunk(self, task: str, *files, cwd=None, **kwargs):
694695
if logging.getLogger().level > logging.INFO:
695696
call_kwargs.update(stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
696697
cmd += self.cmd_opts(task, **kwargs) + list(files)
697-
log_command(cmd, logger=self.job_logger, level=logging.INFO)
698+
log_command(cmd, logger=self.job_logger(), level=logging.INFO)
698699
status = subprocess.call(cmd, **call_kwargs)
699700
if dry_run and status != 0:
700701
lang_str = "/".join(task_config["languages"])

0 commit comments

Comments
 (0)