Skip to content

feat(logging): add opt-in logging of WordPress REST API requests - #863

Draft
josephfusco wants to merge 6 commits into
mainfrom
feat/logging-rest-support
Draft

josephfusco wants to merge 6 commits into
mainfrom
feat/logging-rest-support

Conversation

@josephfusco

@josephfusco josephfusco commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Adds an opt-in setting, off by default, that logs WordPress REST API requests through the existing logger on their own channel. Request headers, including Authorization and Cookie, are stored unsanitized today, so that should be fixed before this ships.

Closes #799

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Assisting with adding REST API request logging.

Log REST API requests through the existing logger pipeline when the new
"Log REST API Requests" setting is enabled (off by default). Entries are
written to the wpgraphql_logging_rest channel, reuse the enabled, IP
restriction, sampling and log response settings, and support a new
"Exclude REST Routes" prefix list.
@josephfusco josephfusco added [Type] Feature A new feature within an existing module [Area] Logging Issues for the WPGraphQL Logging plugin labels Oct 30, 2026
@josephfusco josephfusco added this to the WPGraphQL Logging Plugin milestone Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

📦 Plugin Artifacts Ready!

Download from GitHub Actions run

Available plugins:

  • ✅ wpgraphql-logging.zip

See the "Artifacts" section at the bottom of the Actions run page

josephfusco and others added 5 commits October 30, 2026 15:33
- Accept mixed hook arguments so a third-party apply_filters() call with
  unexpected values cannot fatal a REST response.
- Guard with is_graphql_http_request() instead of is_graphql_request(),
  which is also true while a REST callback runs graphql() and would have
  dropped those REST entries.
- Skip CORS preflight (OPTIONS) requests.
- Do not store error bodies twice when Log Response is enabled.
- Anonymize response.password in the recommended rules so a newly
  created application password is not logged in plain text.
Fill coverage gaps for the REST logger (rule filters, Log Points not
applying, timer reset and nesting, undispatched requests) and add tests
for the new settings fields.

Writing these exposed that route exclusions matched raw string prefixes,
so /wp/v2/users also excluded /wp/v2/users-extra, and were case-sensitive
while WordPress matches routes case-insensitively. Exclusions now match
the route and the routes below it, ignoring case.
…EST logging

- Let the REST logger override a get_logging_rules() hook in
  LoggingHelper instead of copying the rule manager setup.
- Log only the parameters the client sent, not every endpoint default,
  to keep REST entries small.
- Document the REST settings, what is logged, route exclusions,
  sanitization, filtering by channel and the extension points.
The REST channel logger is a shared singleton behind a BufferHandler.
test_serve_filter_value_is_returned_unchanged wrote two records without
reading them, so they stayed buffered past tearDown's delete and were
flushed into the next test, which then saw three entries instead of one.
Flush the buffer in tearDown before deleting entries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Logging Issues for the WPGraphQL Logging plugin [Type] Feature A new feature within an existing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Support REST for WPGraphQL Logging Plugin

1 participant