Skip to content

Commit

Permalink
fix(colab): color log printing (2noise#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama authored Jun 24, 2024
1 parent 25b6023 commit cae0fec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/ipynb/colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion tools/logger/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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

0 comments on commit cae0fec

Please sign in to comment.