Skip to content

New error logger#658

Open
alexander-b-clean wants to merge 16 commits into
devfrom
dev-logger.ab
Open

New error logger#658
alexander-b-clean wants to merge 16 commits into
devfrom
dev-logger.ab

Conversation

@alexander-b-clean
Copy link
Copy Markdown
Contributor

Comment thread lib/CleantalkSP/Common/Enqueue/Enqueue.php Outdated
Comment thread lib/CleantalkSP/Common/Logger.php Outdated
Comment thread lib/CleantalkSP/SpbctWP/FSWatcher/Logger.php Outdated
Comment thread lib/CleantalkSP/SpbctWP/SpbcDevLogger.php
Comment thread lib/CleantalkSP/Common/Enqueue/Enqueue.php Outdated
Comment thread lib/CleantalkSP/Common/Helpers/IP.php Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 introduces a new developer logging mechanism for the plugin and replaces direct error_log() usage with a WordPress-state-backed ring buffer logger, while also enforcing error_log bans via Psalm.

Changes:

  • Added SpbcDevLogger (ring-buffer persisted in State under dev_log) and a base DevLogger.
  • Replaced multiple error_log() call sites with SpbcDevLogger::write() and updated enqueue error reporting to route through an overridable errorWrite().
  • Added Psalm forbidden-function rule for error_log() and introduced PHPUnit coverage for the new logger.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/lib/CleantalkSP/SpbctWP/TestSpbcDevLogger.php Adds PHPUnit coverage for SpbcDevLogger storage, formatting, and ring-buffer behavior.
security-malware-firewall.php Adds SpbcDevLogger import, includes dev_log in State options, and replaces one error_log() call.
psalm.xml Forbids error_log() usage in Psalm.
lib/CleantalkSP/SpbctWP/State.php Adds dev_log defaults, dev_logger property, and includes dev_log in resetState() options.
lib/CleantalkSP/SpbctWP/SpbcRateLimit/SpbcRateLimiter.php Routes rate-limiter debug logging through SpbcDevLogger.
lib/CleantalkSP/SpbctWP/SpbcEnqueue.php Implements errorWrite() to route enqueue errors into SpbcDevLogger.
lib/CleantalkSP/SpbctWP/SpbcDevLogger.php Introduces the new State-persisted ring-buffer developer logger.
lib/CleantalkSP/SpbctWP/Scanner/Surface.php Replaces error_log() with SpbcDevLogger when encountering symlinks during scanning.
lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php Replaces several error_log() calls with SpbcDevLogger and adds structured context logging for one case.
lib/CleantalkSP/SpbctWP/Scanner/FrontendScan.php Stops logging malformed HTML parse errors (commented rationale).
lib/CleantalkSP/SpbctWP/FSWatcher/Logger.php Replaces error_log() file-append logging with file_put_contents() and uses SpbcDevLogger for failures.
lib/CleantalkSP/SpbctWP/Firewall/FW.php Replaces a firewall exception error_log() with SpbcDevLogger.
lib/CleantalkSP/SpbctWP/Deactivator.php Routes deactivation error logging through SpbcDevLogger.
lib/CleantalkSP/SpbctWP/AdjustToEnvironmentModule/AdjustToEnv/AdjustToEnvW3TotalCache.php Replaces error_log() with structured SpbcDevLogger calls.
lib/CleantalkSP/Common/Helpers/IP.php Routes one IPv6-support warning through DevLogger::write() instead of error_log().
lib/CleantalkSP/Common/Helpers/DevLogger.php Adds a base logger wrapper currently implemented via error_log().
lib/CleantalkSP/Common/Enqueue/Enqueue.php Makes Enqueue abstract, replaces direct error_log() with errorWrite(), and renames internal error accumulator method.
inc/spbc-admin.php Replaces admin logging error_log() calls with SpbcDevLogger.
composer.json Adds a new dependency entry (cleantalk/spbct-helpers) alongside existing analyser packages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/CleantalkSP/Common/Helpers/DevLogger.php
Comment thread security-malware-firewall.php
Comment thread lib/CleantalkSP/SpbctWP/Scanner/Surface.php
Comment thread lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php
Comment thread lib/CleantalkSP/Common/Enqueue/Enqueue.php Outdated
Comment thread lib/CleantalkSP/SpbctWP/FSWatcher/Logger.php Outdated
Comment thread lib/CleantalkSP/SpbctWP/State.php
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
* @see https://github.com/CleanTalk/security-malware-firewall
*/
class DevLogger
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need a new class? We have already implemented almost the same

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.

6 participants