fix ugly printed error of uvicorn.error (#1833)

This commit is contained in:
dni ⚡ 2023-07-24 13:25:47 +02:00 committed by GitHub
parent 11fec7a889
commit a81a2b5a08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -483,9 +483,11 @@ def configure_logger() -> None:
logger.remove()
log_level: str = "DEBUG" if settings.debug else "INFO"
formatter = Formatter()
logger.add(sys.stderr, level=log_level, format=formatter.format)
logger.add(sys.stdout, level=log_level, format=formatter.format)
logging.getLogger("uvicorn").handlers = [InterceptHandler()]
logging.getLogger("uvicorn.access").handlers = [InterceptHandler()]
logging.getLogger("uvicorn.error").handlers = [InterceptHandler()]
logging.getLogger("uvicorn.error").propagate = False
class Formatter: