diff --git a/cista/preview.py b/cista/preview.py index 2a1552a..5a9ea91 100644 --- a/cista/preview.py +++ b/cista/preview.py @@ -12,6 +12,7 @@ from urllib.parse import unquote from wsgiref.handlers import format_date_time import httpx +from mediapreview import CachedPreview, PreviewCache, is_previewable_path from mediapreview.formats import OFFICE_PREVIEW_SUFFIXES from mediapreview.formats import expected_backend as _expected_preview_backend from mediapreview.office import onlyoffice_error_short_text @@ -30,7 +31,6 @@ from sanic.log import logger from cista import auth, config, sharefs, watching from cista.fileio import fuid from cista.util.filename import sanitize -from mediapreview import CachedPreview, PreviewCache, is_previewable_path bp = Blueprint("preview", url_prefix="/preview") diff --git a/cista/sanic_logging.py b/cista/sanic_logging.py index 8e38fba..adf9d8b 100644 --- a/cista/sanic_logging.py +++ b/cista/sanic_logging.py @@ -286,9 +286,14 @@ def configure_main_logging() -> None: LOGGING_CONFIG_DEFAULTS["formatters"]["generic"] = { "class": "cista.sanic_logging._EmojiFormatter", } - # Silence websockets' built-in "connection closed" INFO messages; we log WS - # open/close ourselves in the custom access log instead. - logging.getLogger("websockets.server").setLevel(logging.WARNING) + # Sanic passes its "sanic.websockets" logger to websockets' ServerProtocol, + # so "connection closed" (websockets >= 17, INFO) and Sanic's own + # "Websocket timed out waiting for pong" (WARNING) both emit via + # sanic.websockets, not websockets.server. Raise it to ERROR so these + # routine disconnect messages are dropped while real errors still show. + # Patch the config defaults too, so the level survives Sanic's dictConfig. + LOGGING_CONFIG_DEFAULTS["loggers"]["sanic.websockets"]["level"] = "ERROR" + logging.getLogger("sanic.websockets").setLevel(logging.ERROR) # Also reformat any handlers already attached (covers the initial Sanic() call) for name in ("sanic.root", "sanic.error", "sanic.server", "sanic.websockets"): for handler in logging.getLogger(name).handlers: