diff --git a/packages/syft/src/syft/server/uvicorn.py b/packages/syft/src/syft/server/uvicorn.py index 3626db6aa13..953d19a4c2e 100644 --- a/packages/syft/src/syft/server/uvicorn.py +++ b/packages/syft/src/syft/server/uvicorn.py @@ -1,5 +1,6 @@ # stdlib from collections.abc import Callable +import logging import multiprocessing import multiprocessing.synchronize import os @@ -122,7 +123,8 @@ def run_uvicorn( starting_uvicorn_event: multiprocessing.synchronize.Event, **kwargs: Any, ) -> None: - should_reset = kwargs.get("dev_mode") and kwargs.get("reset") + dev_mode = kwargs.get("dev_mode") + should_reset = dev_mode and kwargs.get("reset") if should_reset: print("Found `reset=True` in the launch configuration. Resetting the server...") @@ -140,6 +142,12 @@ def run_uvicorn( except Exception: # nosec print(f"Failed to kill python process on port: {port}") + log_level = "critical" + if dev_mode: + log_level = "info" + logging.getLogger("uvicorn").setLevel(logging.CRITICAL) + logging.getLogger("uvicorn.access").setLevel(logging.CRITICAL) + if kwargs.get("debug"): attach_debugger() @@ -166,8 +174,9 @@ def run_uvicorn( host=host, port=port, factory=True, - reload=kwargs.get("dev_mode"), - reload_dirs=[Path(__file__).parent.parent] if kwargs.get("dev_mode") else None, + reload=dev_mode, + reload_dirs=[Path(__file__).parent.parent] if dev_mode else None, + log_level=log_level, )