Suppress HLS preview segment polling from uvicorn access logs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,10 +8,13 @@ import logging
|
||||
def should_log_uvicorn_access_line(message: str) -> bool:
|
||||
"""Return False to suppress a uvicorn access log line."""
|
||||
msg = message or ""
|
||||
if "GET" in msg and " 200 " in msg and "/health" in msg:
|
||||
if "GET" in msg and '" 200' in msg and "/health" in msg:
|
||||
return False
|
||||
if "GET" in msg and " 404 " in msg and "/pending-confirmation" in msg:
|
||||
return False
|
||||
# HLS 预览反代:m3u8 / fMP4 分片轮询,成功 200 为常态噪声
|
||||
if "GET" in msg and '" 200' in msg and "/internal/demo/hls-preview/" in msg:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -28,3 +28,26 @@ def test_keep_pending_200() -> None:
|
||||
def test_keep_start_post() -> None:
|
||||
line = '192.168.3.85:9999 - "POST /client/surgeries/start HTTP/1.1" 503 Service Unavailable'
|
||||
assert should_log_uvicorn_access_line(line) is True
|
||||
|
||||
|
||||
def test_suppress_hls_preview_m3u8_200() -> None:
|
||||
line = (
|
||||
'172.21.0.1:40496 - "GET /internal/demo/hls-preview/or-cam-02/video1_stream.m3u8'
|
||||
'?session=b7faf66b&_HLS_msn=17&_HLS_part=2&_HLS_skip=YES HTTP/1.1" 200'
|
||||
)
|
||||
assert should_log_uvicorn_access_line(line) is False
|
||||
|
||||
|
||||
def test_suppress_hls_preview_mp4_200() -> None:
|
||||
line = (
|
||||
'172.21.0.1:40472 - "GET /internal/demo/hls-preview/or-cam-02/'
|
||||
'0e238a860dec_video1_part102.mp4?session=b7faf66b HTTP/1.1" 200'
|
||||
)
|
||||
assert should_log_uvicorn_access_line(line) is False
|
||||
|
||||
|
||||
def test_keep_hls_preview_404() -> None:
|
||||
line = (
|
||||
'172.21.0.1:40472 - "GET /internal/demo/hls-preview/or-cam-02/index.m3u8 HTTP/1.1" 404'
|
||||
)
|
||||
assert should_log_uvicorn_access_line(line) is True
|
||||
|
||||
Reference in New Issue
Block a user