add dedicated Typer logger

This commit is contained in:
Faylixe
2020-12-08 14:35:22 +01:00
parent 8a0e420080
commit 6c9a906484
2 changed files with 10 additions and 1 deletions

View File

@@ -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)

View File

@@ -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'))