Add request timing - #3
Closed
nickchomey wants to merge 2 commits into
Closed
nickchomey wants to merge 2 commits into
nickchomey wants to merge 2 commits into
Conversation
Contributor
Author
|
sorry for formatting changes. its automatic... deal with it |
Collaborator
|
No worries. I'll see if I can merge this. Thanks! |
jordantrizz
force-pushed
the
main
branch
3 times, most recently
from
April 12, 2025 00:23
12fe755 to
f1903ef
Compare
jordantrizz
force-pushed
the
main
branch
2 times, most recently
from
October 31, 2025 16:12
ab16fed to
a89988c
Compare
jordantrizz
force-pushed
the
main
branch
5 times, most recently
from
November 24, 2025 15:13
6d985d0 to
9379960
Compare
jordantrizz
force-pushed
the
main
branch
2 times, most recently
from
February 12, 2026 19:50
3b8b9b8 to
9aee364
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds request-duration logging to the Ajax Logger snippet by capturing a start time and writing the final log line during the shutdown hook, so slow requests can be identified more easily.
Changes:
- Capture request start time and append a
Duration: … secondsfield at shutdown. - Route logging through a new
log_execution_time()function (shutdown-time write). - Minor formatting/consistency updates in the PHP file.
Suppressed comments (1)
ajaxlog/ajaxlog.php:20
- This inline comment still refers to “AJAXDEBUG”, but the actual feature flag is
AJAX_DEBUG_ENABLED(checked immediately below). Updating the comment avoids confusion when troubleshooting why no logs are written.
// Only proceed if AJAXDEBUG is enabled in wp-config.php
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+129
to
134
| foreach ($excludes as $exclude) { | ||
| if (strpos($log_message, $exclude) !== false) { | ||
| //ajax_logger_debug($log_file,"[$current_date] excluded text detected ($exclude), not logging"); | ||
| return; | ||
| } | ||
| } |
Comment on lines
12
to
14
| * Original code from - https://stackoverflow.com/questions/69234458/how-to-log-queries-that-go-to-wp-admin-admin-ajax-php | ||
| * Debug, define('AJAXDEBUG','true'); in wp-config.php or user-config.php | ||
| * |
| if (str_contains($_SERVER['REQUEST_URI'],"as_async_request_queue_runner")){ | ||
| $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | ||
|
|
||
| if (str_contains($_SERVER['REQUEST_URI'], "as_async_request_queue_runner")) { |
3 tasks
Collaborator
|
Created a new PR with small modifications to enable merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
logs the request duration as well. Not perfect - timing starts when the MU plugin loads, but its close enough . Especially when we want to inspect slow requests