Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove noisy debug logs #165

Merged
merged 5 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/face_landmark/face_landmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 24 additions & 11 deletions livekit-rtc/livekit/rtc/_ffi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,24 @@ 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
elif which == "panic":
Expand All @@ -155,7 +165,7 @@ def ffi_event_callback(
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:
Expand All @@ -165,9 +175,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 logs 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:
Expand Down
Loading