@@ -297,6 +297,8 @@ def execute(self, command, params):
297
297
del params [word ]
298
298
data = utils .dump_json (params )
299
299
url = f"{ self ._url } { path } "
300
+ trimmed = self ._trim_large_entries (params )
301
+ LOGGER .debug ("%s %s %s" , command_info [0 ], url , str (trimmed ))
300
302
return self ._request (command_info [0 ], url , body = data )
301
303
302
304
def _request (self , method , url , body = None ):
@@ -310,7 +312,6 @@ def _request(self, method, url, body=None):
310
312
:Returns:
311
313
A dictionary with the server's parsed JSON response.
312
314
"""
313
- LOGGER .debug ("%s %s %s" , method , url , body )
314
315
parsed_url = parse .urlparse (url )
315
316
headers = self .get_remote_connection_headers (parsed_url , self .keep_alive )
316
317
response = None
@@ -360,3 +361,21 @@ def close(self):
360
361
"""Clean up resources when finished with the remote_connection."""
361
362
if hasattr (self , "_conn" ):
362
363
self ._conn .clear ()
364
+
365
+ def _trim_large_entries (self , input_dict , max_length = 100 ):
366
+ """Truncate string values in a dictionary if they exceed max_length.
367
+
368
+ :param dict: Dictionary with potentially large values
369
+ :param max_length: Maximum allowed length of string values
370
+ :return: Dictionary with truncated string values
371
+ """
372
+ output_dictionary = {}
373
+ for key , value in input_dict .items ():
374
+ if isinstance (value , dict ):
375
+ output_dictionary [key ] = self ._trim_large_entries (value , max_length )
376
+ elif isinstance (value , str ) and len (value ) > max_length :
377
+ output_dictionary [key ] = value [:max_length ] + "..."
378
+ else :
379
+ output_dictionary [key ] = value
380
+
381
+ return output_dictionary
0 commit comments