Skip to content

Commit 1430c95

Browse files
authored
feat(ipynb): apply logger to notebook (#410)
1 parent 7fecdb8 commit 1430c95

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

examples/ipynb/colab.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"torch.set_float32_matmul_precision('high')\n",
5151
"\n",
5252
"from ChatTTS import ChatTTS\n",
53+
"from ChatTTS.tools.logger import get_logger\n",
5354
"from IPython.display import Audio"
5455
]
5556
},
@@ -70,7 +71,7 @@
7071
},
7172
"outputs": [],
7273
"source": [
73-
"chat = ChatTTS.Chat()"
74+
"chat = ChatTTS.Chat(get_logger(\"ChatTTS\"))"
7475
]
7576
},
7677
{

examples/ipynb/example.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"torch.set_float32_matmul_precision('high')\n",
3434
"\n",
3535
"import ChatTTS\n",
36+
"from tools.logger import get_logger\n",
3637
"from IPython.display import Audio"
3738
]
3839
},
@@ -51,7 +52,7 @@
5152
"source": [
5253
"os.chdir(root_dir)\n",
5354
"\n",
54-
"chat = ChatTTS.Chat()"
55+
"chat = ChatTTS.Chat(get_logger(\"ChatTTS\"))"
5556
]
5657
},
5758
{

tools/logger/log.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import platform
22
import logging
33
from datetime import datetime, timezone
4+
from functools import lru_cache
45

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

51+
@lru_cache(maxsize=None)
5052
def get_logger(name: str, lv = logging.INFO):
5153
logger = logging.getLogger(name)
5254
syslog = logging.StreamHandler()

0 commit comments

Comments
 (0)