Another attempt at silencing useless WebSocket log noise.
This commit is contained in:
+1
-1
@@ -12,6 +12,7 @@ from urllib.parse import unquote
|
|||||||
from wsgiref.handlers import format_date_time
|
from wsgiref.handlers import format_date_time
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
from mediapreview import CachedPreview, PreviewCache, is_previewable_path
|
||||||
from mediapreview.formats import OFFICE_PREVIEW_SUFFIXES
|
from mediapreview.formats import OFFICE_PREVIEW_SUFFIXES
|
||||||
from mediapreview.formats import expected_backend as _expected_preview_backend
|
from mediapreview.formats import expected_backend as _expected_preview_backend
|
||||||
from mediapreview.office import onlyoffice_error_short_text
|
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 import auth, config, sharefs, watching
|
||||||
from cista.fileio import fuid
|
from cista.fileio import fuid
|
||||||
from cista.util.filename import sanitize
|
from cista.util.filename import sanitize
|
||||||
from mediapreview import CachedPreview, PreviewCache, is_previewable_path
|
|
||||||
|
|
||||||
bp = Blueprint("preview", url_prefix="/preview")
|
bp = Blueprint("preview", url_prefix="/preview")
|
||||||
|
|
||||||
|
|||||||
@@ -286,9 +286,14 @@ def configure_main_logging() -> None:
|
|||||||
LOGGING_CONFIG_DEFAULTS["formatters"]["generic"] = {
|
LOGGING_CONFIG_DEFAULTS["formatters"]["generic"] = {
|
||||||
"class": "cista.sanic_logging._EmojiFormatter",
|
"class": "cista.sanic_logging._EmojiFormatter",
|
||||||
}
|
}
|
||||||
# Silence websockets' built-in "connection closed" INFO messages; we log WS
|
# Sanic passes its "sanic.websockets" logger to websockets' ServerProtocol,
|
||||||
# open/close ourselves in the custom access log instead.
|
# so "connection closed" (websockets >= 17, INFO) and Sanic's own
|
||||||
logging.getLogger("websockets.server").setLevel(logging.WARNING)
|
# "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)
|
# Also reformat any handlers already attached (covers the initial Sanic() call)
|
||||||
for name in ("sanic.root", "sanic.error", "sanic.server", "sanic.websockets"):
|
for name in ("sanic.root", "sanic.error", "sanic.server", "sanic.websockets"):
|
||||||
for handler in logging.getLogger(name).handlers:
|
for handler in logging.getLogger(name).handlers:
|
||||||
|
|||||||
Reference in New Issue
Block a user