@@ -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
173186class FfiClient :
0 commit comments