提交 6c9a9064 编写于 作者: F Faylixe

add dedicated Typer logger

上级 8a0e4200
......@@ -11,6 +11,7 @@ from os import environ
# pyright: reportMissingImports=false
# pylint: disable=import-error
from tensorflow.compat.v1 import logging as tflogging
from typer import echo
# pylint: enable=import-error
__email__ = 'spleeter@deezer.com'
......@@ -18,8 +19,15 @@ __author__ = 'Deezer Research'
__license__ = 'MIT License'
class TyperLoggerHandler(logging.Handler):
""" A custom logger handler that use Typer echo. """
def emit(self, record: logging.LogRecord) -> None:
echo(self.format(record))
formatter = logging.Formatter('%(levelname)s:%(name)s:%(message)s')
handler = logging.StreamHandler()
handler = TyperLoggerHandler()
handler.setFormatter(formatter)
logger: logging.Logger = logging.getLogger('spleeter')
logger.addHandler(handler)
......
......@@ -101,6 +101,7 @@ def test_train():
'-p', 'useless_config.json',
'-d', path
])
raise IOError(f'STDOUT: {result.stdout}, STDERR: {result.stderr}')
assert result.exit_code == 0
# assert that model checkpoint was created.
assert os.path.exists(join(path, 'model', 'model.ckpt-10.index'))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册