Revert changes to setup_logger. (#468)

This commit is contained in:
Fangjun Kuang 2022-07-08 09:15:37 +08:00 committed by GitHub
parent 8761452a2c
commit e5fdbcd480
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,8 +96,6 @@ def str2bool(v):
def setup_logger(
log_filename: Pathlike,
log_level: str = "info",
rank: int = 0,
world_size: int = 1,
use_console: bool = True,
) -> None:
"""Setup log level.
@ -108,16 +106,14 @@ def setup_logger(
log_level:
The log level to use, e.g., "debug", "info", "warning", "error",
"critical"
rank:
Rank of this node in DDP training.
world_size:
Number of nodes in DDP training.
use_console:
True to also print logs to console.
"""
now = datetime.now()
date_time = now.strftime("%Y-%m-%d-%H-%M-%S")
if world_size > 1:
if dist.is_available() and dist.is_initialized():
world_size = dist.get_world_size()
rank = dist.get_rank()
formatter = f"%(asctime)s %(levelname)s [%(filename)s:%(lineno)d] ({rank}/{world_size}) %(message)s" # noqa
log_filename = f"{log_filename}-{date_time}-{rank}"
else: