From a2af811ad29ccd573d5ddbd5497b51bab8e5783a Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Fri, 9 Dec 2022 22:47:34 +0530 Subject: [PATCH] Disable uvicorn access logging in favor of cleaner server-side logging, we already get all that info; Print the request metadata --- scripts/on_sd_start.bat | 2 +- scripts/on_sd_start.sh | 2 +- ui/sd_internal/app.py | 6 +++--- ui/sd_internal/runtime2.py | 1 + ui/sd_internal/task_manager.py | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 9bac3757..5f1bfcb1 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -393,7 +393,7 @@ call python --version @if NOT DEFINED SD_UI_BIND_PORT set SD_UI_BIND_PORT=9000 @if NOT DEFINED SD_UI_BIND_IP set SD_UI_BIND_IP=0.0.0.0 -@uvicorn server:server_api --app-dir "%SD_UI_PATH%" --port %SD_UI_BIND_PORT% --host %SD_UI_BIND_IP% +@uvicorn server:server_api --app-dir "%SD_UI_PATH%" --port %SD_UI_BIND_PORT% --host %SD_UI_BIND_IP% --log-level critical @pause diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index afb95295..f4f540e7 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -322,6 +322,6 @@ cd .. export SD_UI_PATH=`pwd`/ui cd stable-diffusion -uvicorn server:server_api --app-dir "$SD_UI_PATH" --port ${SD_UI_BIND_PORT:-9000} --host ${SD_UI_BIND_IP:-0.0.0.0} +uvicorn server:server_api --app-dir "$SD_UI_PATH" --port ${SD_UI_BIND_PORT:-9000} --host ${SD_UI_BIND_IP:-0.0.0.0} --log-level critical read -p "Press any key to continue" diff --git a/ui/sd_internal/app.py b/ui/sd_internal/app.py index c34f2ea6..bfb90399 100644 --- a/ui/sd_internal/app.py +++ b/ui/sd_internal/app.py @@ -8,12 +8,12 @@ from rich.logging import RichHandler from sd_internal import task_manager -LOG_FORMAT = '[%(threadName)s] %(message)s' +LOG_FORMAT = '%(levelname)s %(threadName)s %(message)s' logging.basicConfig( level=logging.INFO, format=LOG_FORMAT, - datefmt="[%X.%f]", - handlers=[RichHandler(markup=True)] + datefmt="%X.%f", + handlers=[RichHandler(markup=True, rich_tracebacks=True, show_level=False)] ) log = logging.getLogger() diff --git a/ui/sd_internal/runtime2.py b/ui/sd_internal/runtime2.py index c7845079..cdffa574 100644 --- a/ui/sd_internal/runtime2.py +++ b/ui/sd_internal/runtime2.py @@ -70,6 +70,7 @@ def reload_models_if_necessary(req: Request): def make_images(req: Request, data_queue: queue.Queue, task_temp_images: list, step_callback): try: + log.info(req) return _make_images_internal(req, data_queue, task_temp_images, step_callback) except Exception as e: log.error(traceback.format_exc()) diff --git a/ui/sd_internal/task_manager.py b/ui/sd_internal/task_manager.py index 852631c6..4eb45ce6 100644 --- a/ui/sd_internal/task_manager.py +++ b/ui/sd_internal/task_manager.py @@ -19,7 +19,7 @@ from sd_internal import Request, device_manager log = logging.getLogger() -THREAD_NAME_PREFIX = 'Runtime-Render/' +THREAD_NAME_PREFIX = '' ERR_LOCK_FAILED = ' failed to acquire lock within timeout.' LOCK_TIMEOUT = 15 # Maximum locking time in seconds before failing a task. # It's better to get an exception than a deadlock... ALWAYS use timeout in critical paths.