diff --git a/examples/ipynb/colab.ipynb b/examples/ipynb/colab.ipynb index 0ef9f581c..416f42e73 100644 --- a/examples/ipynb/colab.ipynb +++ b/examples/ipynb/colab.ipynb @@ -72,7 +72,7 @@ }, "outputs": [], "source": [ - "logger = get_logger(\"ChatTTS\", remove_exist=True)\n", + "logger = get_logger(\"ChatTTS\", format_root=True)\n", "chat = ChatTTS.Chat(logger)\n", "\n", "# try to load normalizer\n", diff --git a/tools/logger/log.py b/tools/logger/log.py index 4400116d7..603a7d5a2 100644 --- a/tools/logger/log.py +++ b/tools/logger/log.py @@ -51,7 +51,7 @@ def format(self, record: logging.LogRecord): return logstr -def get_logger(name: str, lv = logging.INFO, remove_exist=False): +def get_logger(name: str, lv = logging.INFO, remove_exist=False, format_root=False): logger = logging.getLogger(name) logger.setLevel(lv) if remove_exist and logger.hasHandlers(): @@ -63,4 +63,7 @@ def get_logger(name: str, lv = logging.INFO, remove_exist=False): else: for h in logger.handlers: h.setFormatter(Formatter()) + if format_root: + for h in logger.root.handlers: + h.setFormatter(Formatter()) return logger