Skip to content

Commit

Permalink
clear log handlers before setup (#1603)
Browse files Browse the repository at this point in the history
  • Loading branch information
yfyeung authored Apr 24, 2024
1 parent 9f8f0bc commit 368b7d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions icefall/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ def str2bool(v):
raise argparse.ArgumentTypeError("Boolean value expected.")


def clear_log_handlers():
logger = logging.getLogger()
handlers = logger.handlers[:]
for handler in handlers:
logger.removeHandler(handler)


def setup_logger(
log_filename: Pathlike,
log_level: str = "info",
Expand All @@ -126,6 +133,8 @@ def setup_logger(
use_console:
True to also print logs to console.
"""
clear_log_handlers()

now = datetime.now()
date_time = now.strftime("%Y-%m-%d-%H-%M-%S")
if dist.is_available() and dist.is_initialized():
Expand Down

0 comments on commit 368b7d1

Please sign in to comment.