Skip to content

fix(logger): route warn-level events to Hypercart_Logger::warning()#39

Open
mrtwebdesign wants to merge 2 commits into
developmentfrom
fix/7-logger-warning-bridge
Open

fix(logger): route warn-level events to Hypercart_Logger::warning()#39
mrtwebdesign wants to merge 2 commits into
developmentfrom
fix/7-logger-warning-bridge

Conversation

@mrtwebdesign
Copy link
Copy Markdown
Contributor

Summary

QueryGuard's logging bridge checked for and called a warn() method, but the Hypercart Helper logger (Hypercart-Helper-WP-plugin/includes/class-hypercart-logger.php) exposes warning(). The method_exists() guard therefore always returned false, so every warn-level event — including slow_query, the most common event in observe mode — silently fell back to error_log() instead of landing in wp-content/hypercart-logs/. info and error routed correctly; only warn was broken.

This was confirmed against ~48h of binoidcbd production logs: 551 slow_query events, all in the WP Engine PHP error log, none in the Helper log files.

Changes

  • hypercart-query-guard.php — bridge now prefers Hypercart_Logger::warning(), with warn() kept as a fallback for any string-only/legacy logger. Docblock attribution corrected to the Helper plugin.
  • class-hcqg-mutex-guard.php — same bridge bug fixed (it logs kill/mutex events).
  • README.md — logging section now credits the Hypercart Helper plugin, not the Performance Monitor.
  • Tests — mock Hypercart_Logger made faithful to the real class (warning), new test_warn_level_routes_to_hypercart_logger_warning regression, and the end-to-end DbDropinTest assertion updated. Full suite green: 86 tests, 166 assertions.

Scope notes

  • Conservative on purpose: no internal warnwarning rename and the public WARN_THRESHOLD_MS / HYPERCART_QUERY_GUARD_WARN_THRESHOLD_MS config constant is untouched.
  • The early-load concern was investigated and is a non-issue: slow-query and kill logging fire on the shutdown hook, well after the Helper plugin loads, so Hypercart_Logger is available when these events are written.
  • Deployment reminder: to see logs land on a site, the fixed plugin files must be deployed (not just db.php) and the Hypercart Helper plugin must be active.

Issues

Closes #7
Closes #6

🤖 Generated with Claude Code

mrtwebdesign and others added 2 commits May 29, 2026 16:46
The logging bridge checked for and called a warn() method, but the Hypercart Helper logger exposes warning(). The method_exists() guard always failed, so every warn-level event — including slow_query, the most common event in observe mode — silently fell back to error_log() instead of reaching wp-content/hypercart-logs/.

Prefer warning() in both the main plugin and the mutex guard bridge, keeping warn() as a fallback for any string-only/legacy logger. Make the test mock faithful to the real class and add regression coverage pinning warn-level routing through to warning().

Also corrects the log() docblock to attribute the logger to the Helper plugin.

Closes #7
Refs #6

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e Monitor

Hypercart_Logger is defined in Hypercart-Helper-WP-plugin; the Performance Monitor plugin only consumes it. Update the README logging section so it points to the plugin that actually defines the class.

Closes #6

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant