From f31068f40fe751b3cf7b3e925f56e09538a0c304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=CC=81o=20Monnom?= Date: Wed, 14 Feb 2024 15:35:46 +0100 Subject: [PATCH 1/4] remove noisy debug logs --- examples/basic_room.py | 2 +- livekit-rtc/livekit/rtc/_ffi_client.py | 35 ++++++++++++++++++-------- livekit-rtc/rust-sdks | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/examples/basic_room.py b/examples/basic_room.py index 7d1544b5..87d48f74 100644 --- a/examples/basic_room.py +++ b/examples/basic_room.py @@ -147,7 +147,7 @@ def on_reconnected() -> None: if __name__ == "__main__": logging.basicConfig( - level=logging.INFO, + level=logging.DEBUG, handlers=[logging.FileHandler("basic_room.log"), logging.StreamHandler()], ) diff --git a/livekit-rtc/livekit/rtc/_ffi_client.py b/livekit-rtc/livekit/rtc/_ffi_client.py index a1711d11..f9245257 100644 --- a/livekit-rtc/livekit/rtc/_ffi_client.py +++ b/livekit-rtc/livekit/rtc/_ffi_client.py @@ -135,21 +135,31 @@ def ffi_event_callback( which = event.WhichOneof("message") if which == "logs": for record in event.logs.records: - logger.log( - to_python_level(record.level), - "%s:%s:%s - %s", - record.target, - record.line, - record.module_path, - record.message, - ) + level = to_python_level(record.level) + rtc_debug = os.environ.get("LIVEKIT_WEBRTC_DEBUG", "").strip() + if ( + record.target == "libwebrtc" + and level == logging.DEBUG + and rtc_debug.lower() not in ("true", "1") + ): + continue + + if level is not None: + logger.log( + level, + "%s:%s:%s - %s", + record.target, + record.line, + record.module_path, + record.message, + ) return # no need to queue the logs FfiClient.instance.queue.put(event) -def to_python_level(level: proto_ffi.LogLevel.ValueType) -> int: +def to_python_level(level: proto_ffi.LogLevel.ValueType) -> Optional[int]: if level == proto_ffi.LogLevel.LOG_ERROR: return logging.ERROR elif level == proto_ffi.LogLevel.LOG_WARN: @@ -159,9 +169,12 @@ def to_python_level(level: proto_ffi.LogLevel.ValueType) -> int: elif level == proto_ffi.LogLevel.LOG_DEBUG: return logging.DEBUG elif level == proto_ffi.LogLevel.LOG_TRACE: - return logging.DEBUG + # Don't show TRACE bug inside DEBUG, it is too verbos + # Python's logging doesn't have a TRACE level + # return logging.DEBUG + pass - raise Exception("unreachable") + return None class FfiClient: diff --git a/livekit-rtc/rust-sdks b/livekit-rtc/rust-sdks index 4450c6ca..8aa9eb31 160000 --- a/livekit-rtc/rust-sdks +++ b/livekit-rtc/rust-sdks @@ -1 +1 @@ -Subproject commit 4450c6ca5cf269873db5debf5fc06115490a44ea +Subproject commit 8aa9eb3181b6efeb96b0a73e30acc8da7803a318 From 75325ca0282c5c6296d564ca0af9a2efcbff8ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=CC=81o=20Monnom?= Date: Wed, 14 Feb 2024 15:38:02 +0100 Subject: [PATCH 2/4] fix ruff --- examples/basic_room.py | 2 +- examples/face_landmark/face_landmark.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/basic_room.py b/examples/basic_room.py index 87d48f74..7d1544b5 100644 --- a/examples/basic_room.py +++ b/examples/basic_room.py @@ -147,7 +147,7 @@ def on_reconnected() -> None: if __name__ == "__main__": logging.basicConfig( - level=logging.DEBUG, + level=logging.INFO, handlers=[logging.FileHandler("basic_room.log"), logging.StreamHandler()], ) diff --git a/examples/face_landmark/face_landmark.py b/examples/face_landmark/face_landmark.py index b61d8169..edc20f36 100644 --- a/examples/face_landmark/face_landmark.py +++ b/examples/face_landmark/face_landmark.py @@ -103,6 +103,7 @@ def draw_landmarks_on_image(rgb_image, detection_result): async def frame_loop(video_stream: rtc.VideoStream) -> None: + landmarker = FaceLandmarker.create_from_options(options) cv2.namedWindow("livekit_video", cv2.WINDOW_AUTOSIZE) cv2.startWindowThread() async for frame_event in video_stream: From 0c8aaa64c914f82eb5d8baefe6dc3567331850a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=CC=81o=20Monnom?= Date: Wed, 14 Feb 2024 15:38:36 +0100 Subject: [PATCH 3/4] Update _ffi_client.py --- livekit-rtc/livekit/rtc/_ffi_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/livekit-rtc/livekit/rtc/_ffi_client.py b/livekit-rtc/livekit/rtc/_ffi_client.py index f9245257..47ce55b1 100644 --- a/livekit-rtc/livekit/rtc/_ffi_client.py +++ b/livekit-rtc/livekit/rtc/_ffi_client.py @@ -169,7 +169,7 @@ def to_python_level(level: proto_ffi.LogLevel.ValueType) -> Optional[int]: elif level == proto_ffi.LogLevel.LOG_DEBUG: return logging.DEBUG elif level == proto_ffi.LogLevel.LOG_TRACE: - # Don't show TRACE bug inside DEBUG, it is too verbos + # Don't show TRACE logs inside DEBUG, it is too verbos # Python's logging doesn't have a TRACE level # return logging.DEBUG pass From e619ca8c3395a06e972314a246c9d3a8b808899b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?The=CC=81o=20Monnom?= Date: Wed, 14 Feb 2024 20:14:03 +0100 Subject: [PATCH 4/4] Update rust-sdks --- livekit-rtc/rust-sdks | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/livekit-rtc/rust-sdks b/livekit-rtc/rust-sdks index 8aa9eb31..799e95da 160000 --- a/livekit-rtc/rust-sdks +++ b/livekit-rtc/rust-sdks @@ -1 +1 @@ -Subproject commit 8aa9eb3181b6efeb96b0a73e30acc8da7803a318 +Subproject commit 799e95da8cc30456465ed145403d273018721c28