You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe your use case and the problem you are facing
After #6036, one idea that came up is that right now there isn't any visibility into all the outgoing HTTP requests made by WP-CLI.
Such information could be really useful though for debugging and identifying slow parts of the code base.
Describe the solution you'd like
Some ideas on how the HTTP request logging could be implemented:
Add new bootstrap step that hooks into the http_request_options CLI hook and the pre_http_request WP hook (in \WP_CLI\Runner::setup_bootstrap_hooks perhaps?)
Theoretically for the http_request() function we could just add a WP_CLI::debug() line there, no need to use any hooks. But then the file saving wouldn't be feasible.
The http_request_options hook would be more useful if we'd pass the additional args as well, i.e. $method, $url, $data, $headers
The full request & response info could optionally be written to a log file
Not sure what the best approach would be there, don't think we do that anywhere else.
Assuming we only do this for tests, then this could be done in the test directory. And then using the hook makes sense.
Activity
swissspidy commentedon Feb 11, 2025
Theoretically for the
http_request()function we could just add aWP_CLI::debug()line there, no need to use any hooks. But then the file saving wouldn't be feasible.The
http_request_optionshook would be more useful if we'd pass the additional args as well, i.e.$method,$url,$data,$headersNot sure what the best approach would be there, don't think we do that anywhere else.
Assuming we only do this for tests, then this could be done in the test directory. And then using the hook makes sense.
Add HTTP request file logging support for wp-cli#6044
Add HTTP request logging feature (wp-cli#6044)