🌐 AI搜索 & 代理 主页
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 30, 2025

Implementation Plan for HTTP Request Logging

  • Add HTTP request logging hook in Runner::setup_bootstrap_hooks()
    • Hook into http_request_options CLI hook to log WP-CLI's http_request() calls
    • Hook into pre_http_request WP hook to log WordPress HTTP API calls
    • Use WP_CLI::debug() with 'http' debug group
  • Enhance http_request_options hook to pass additional parameters ($method, $url, $data, $headers)
  • Add tests for HTTP request logging
    • PHPUnit test for hook parameters
    • Behat feature tests for integration testing
  • Test with --debug=http flag to verify logging works
    • Verified with demo script showing correct output
  • Clean up unintended changes to composer.json
Original prompt

This section details on the original issue you should resolve

<issue_title>Add HTTP request logging</issue_title>
<issue_description>## Feature Request

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?)
  • The hook would would only print a minimal debug message such as HTTP POST request to https://....
    • This would use a dedicated http debug group
  • The full request & response info could optionally be written to a log file (useful for Behat tests)
    • How could this be made opt-in?</issue_description>

Comments on the Issue (you are @copilot in this section)

@swissspidy 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.</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits October 30, 2025 12:51
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review October 31, 2025 00:21
@swissspidy swissspidy requested a review from a team as a code owner October 31, 2025 00:21
@swissspidy swissspidy changed the title [WIP] Add HTTP request logging for WP-CLI Add HTTP request logging for WP-CLI Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add HTTP request logging

2 participants