Skip to content

Commit

Permalink
feat(ipynb): apply logger to notebook (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama authored Jun 22, 2024
1 parent 7fecdb8 commit 1430c95
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion examples/ipynb/colab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"torch.set_float32_matmul_precision('high')\n",
"\n",
"from ChatTTS import ChatTTS\n",
"from ChatTTS.tools.logger import get_logger\n",
"from IPython.display import Audio"
]
},
Expand All @@ -70,7 +71,7 @@
},
"outputs": [],
"source": [
"chat = ChatTTS.Chat()"
"chat = ChatTTS.Chat(get_logger(\"ChatTTS\"))"
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion examples/ipynb/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"torch.set_float32_matmul_precision('high')\n",
"\n",
"import ChatTTS\n",
"from tools.logger import get_logger\n",
"from IPython.display import Audio"
]
},
Expand All @@ -51,7 +52,7 @@
"source": [
"os.chdir(root_dir)\n",
"\n",
"chat = ChatTTS.Chat()"
"chat = ChatTTS.Chat(get_logger(\"ChatTTS\"))"
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions tools/logger/log.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import platform
import logging
from datetime import datetime, timezone
from functools import lru_cache

logging.getLogger("numba").setLevel(logging.WARNING)
logging.getLogger("httpx").setLevel(logging.WARNING)
Expand Down Expand Up @@ -47,6 +48,7 @@ def format(self, record: logging.LogRecord):
logstr += f"] {str(record.name)} | {str(record.msg)%record.args}"
return logstr

@lru_cache(maxsize=None)
def get_logger(name: str, lv = logging.INFO):
logger = logging.getLogger(name)
syslog = logging.StreamHandler()
Expand Down

0 comments on commit 1430c95

Please sign in to comment.