@@ -136,14 +136,24 @@ def ffi_event_callback(
136
136
which = event .WhichOneof ("message" )
137
137
if which == "logs" :
138
138
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
+ )
147
157
148
158
return # no need to queue the logs
149
159
elif which == "panic" :
@@ -155,7 +165,7 @@ def ffi_event_callback(
155
165
FfiClient .instance .queue .put (event )
156
166
157
167
158
- def to_python_level (level : proto_ffi .LogLevel .ValueType ) -> int :
168
+ def to_python_level (level : proto_ffi .LogLevel .ValueType ) -> Optional [ int ] :
159
169
if level == proto_ffi .LogLevel .LOG_ERROR :
160
170
return logging .ERROR
161
171
elif level == proto_ffi .LogLevel .LOG_WARN :
@@ -165,9 +175,12 @@ def to_python_level(level: proto_ffi.LogLevel.ValueType) -> int:
165
175
elif level == proto_ffi .LogLevel .LOG_DEBUG :
166
176
return logging .DEBUG
167
177
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
169
182
170
- raise Exception ( "unreachable" )
183
+ return None
171
184
172
185
173
186
class FfiClient :
0 commit comments