Skip to content

Commit c6c19a5

Browse files
authored
remove noisy debug logs (#165)
1 parent a06adc7 commit c6c19a5

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

examples/face_landmark/face_landmark.py

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def draw_landmarks_on_image(rgb_image, detection_result):
103103

104104

105105
async def frame_loop(video_stream: rtc.VideoStream) -> None:
106+
landmarker = FaceLandmarker.create_from_options(options)
106107
cv2.namedWindow("livekit_video", cv2.WINDOW_AUTOSIZE)
107108
cv2.startWindowThread()
108109
async for frame_event in video_stream:

livekit-rtc/livekit/rtc/_ffi_client.py

+24-11
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,24 @@ def ffi_event_callback(
136136
which = event.WhichOneof("message")
137137
if which == "logs":
138138
for record in event.logs.records:
139-
logger.log(
140-
to_python_level(record.level),
141-
"%s:%s:%s - %s",
142-
record.target,
143-
record.line,
144-
record.module_path,
145-
record.message,
146-
)
139+
level = to_python_level(record.level)
140+
rtc_debug = os.environ.get("LIVEKIT_WEBRTC_DEBUG", "").strip()
141+
if (
142+
record.target == "libwebrtc"
143+
and level == logging.DEBUG
144+
and rtc_debug.lower() not in ("true", "1")
145+
):
146+
continue
147+
148+
if level is not None:
149+
logger.log(
150+
level,
151+
"%s:%s:%s - %s",
152+
record.target,
153+
record.line,
154+
record.module_path,
155+
record.message,
156+
)
147157

148158
return # no need to queue the logs
149159
elif which == "panic":
@@ -155,7 +165,7 @@ def ffi_event_callback(
155165
FfiClient.instance.queue.put(event)
156166

157167

158-
def to_python_level(level: proto_ffi.LogLevel.ValueType) -> int:
168+
def to_python_level(level: proto_ffi.LogLevel.ValueType) -> Optional[int]:
159169
if level == proto_ffi.LogLevel.LOG_ERROR:
160170
return logging.ERROR
161171
elif level == proto_ffi.LogLevel.LOG_WARN:
@@ -165,9 +175,12 @@ def to_python_level(level: proto_ffi.LogLevel.ValueType) -> int:
165175
elif level == proto_ffi.LogLevel.LOG_DEBUG:
166176
return logging.DEBUG
167177
elif level == proto_ffi.LogLevel.LOG_TRACE:
168-
return logging.DEBUG
178+
# Don't show TRACE logs inside DEBUG, it is too verbos
179+
# Python's logging doesn't have a TRACE level
180+
# return logging.DEBUG
181+
pass
169182

170-
raise Exception("unreachable")
183+
return None
171184

172185

173186
class FfiClient:

0 commit comments

Comments
 (0)