Skip to content

Add request timing - #3

Closed
nickchomey wants to merge 2 commits into
managingwp:mainfrom
nickchomey:patch-3
Closed

nickchomey wants to merge 2 commits into
managingwp:mainfrom
nickchomey:patch-3

Conversation

@nickchomey

Copy link
Copy Markdown
Contributor

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

@nickchomey

Copy link
Copy Markdown
Contributor Author

sorry for formatting changes. its automatic... deal with it

@jordantrizz

Copy link
Copy Markdown
Collaborator

No worries. I'll see if I can merge this. Thanks!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: … seconds field 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 thread ajaxlog/ajaxlog.php
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 thread ajaxlog/ajaxlog.php
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
*
Comment thread ajaxlog/ajaxlog.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")) {
Copilot AI mentioned this pull request Aug 20, 2026
3 tasks
@jordantrizz

Copy link
Copy Markdown
Collaborator

Created a new PR with small modifications to enable merge.

#4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants