eric-maynard commented on code in PR #2154:
URL: https://github.com/apache/polaris/pull/2154#discussion_r2242440098


##########
client/python/cli/polaris_cli.py:
##########
@@ -72,11 +74,33 @@ def execute(args=None):
 
                     admin_api = PolarisDefaultApi(api_client)
                     command = Command.from_options(options)
+                    if options.debug:
+                        PolarisCli._enable_api_request_logging()
                     command.execute(admin_api)
                 except Exception as e:
                     PolarisCli._try_print_exception(e)
                     sys.exit(1)
 
+    @staticmethod
+    def _enable_api_request_logging():
+        # Store the original urlopen method
+        if not hasattr(urllib3.PoolManager, "original_urlopen"):
+            urllib3.PoolManager.original_urlopen = urllib3.PoolManager.urlopen
+
+        # Define the wrapper function
+        @functools.wraps(urllib3.PoolManager.original_urlopen)
+        def urlopen_wrapper(self, method, url, **kwargs):
+            sys.stderr.write(f"Request: {method} {url}\n")
+            if "headers" in kwargs:
+                sys.stderr.write(f"Headers: {kwargs['headers']}\n")
+            if "body" in kwargs:
+                sys.stderr.write(f"Body: {kwargs['body']}\n")
+            sys.stderr.write("\n")

Review Comment:
   nit: looks like this newline is not needed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to