Skip to content

feat(#751): add datamachine/read-debug-log ability for PHP diagnostics#754

Merged
chubes4 merged 1 commit intoExtra-Chill:mainfrom
saraichinwag:feat/751-read-debug-log-ability
Mar 9, 2026
Merged

feat(#751): add datamachine/read-debug-log ability for PHP diagnostics#754
chubes4 merged 1 commit intoExtra-Chill:mainfrom
saraichinwag:feat/751-read-debug-log-ability

Conversation

@saraichinwag
Copy link
Contributor

Summary

Adds ability for the system agent to read wp-content/debug.log for PHP-level error diagnostics. Enables self-debugging of fatal errors, warnings, notices, and deprecation warnings.

New Ability: datamachine/read-debug-log

Input:

  • lines — Number of lines to read from end of file (default: 100, max: 1000)
  • level — Filter by PHP error level: error, warning, notice, deprecated, fatal, parse, all
  • since — ISO datetime filter — entries after this time
  • search — Free-text search in log messages
  • context — Lines of context around each match (default: 0)

Output:

{
  "success": true,
  "file": "/var/www/wp-content/debug.log",
  "entries": [
    {
      "raw": "[09-Mar-2026 14:30:00 UTC] PHP Fatal error: ...",
      "timestamp": 1741530600,
      "datetime": "2026-03-09T14:30:00+00:00",
      "level": "FATAL",
      "message": "Uncaught Exception in /path/to/file.php",
      "file": "/path/to/file.php",
      "line": 42
    }
  ],
  "total": 1,
  "filtered": 1,
  "file_size": 12345,
  "last_modified": "2026-03-09T14:30:00+00:00"
}

Use Cases

  1. Self-debugging — Agent reads debug.log to diagnose PHP-level issues
  2. Issue filing — Agent identifies plugin causing errors and files issue in correct repo
  3. Proactive monitoring — Scheduled flow checks for new fatal errors and alerts

Changes

  • inc/Abilities/LogAbilities.php — add readDebugLog, tailDebugLog, parseDebugLogLine, normalizeLogLevel
  • tests/Unit/Abilities/LogAbilitiesTest.php — 5 new tests for debug log parsing

Testing

14/16 tests pass. 2 pre-existing failures (ClearLogs tests) unchanged.

Related to #751

Adds ability for the system agent to read wp-content/debug.log for
PHP-level error diagnostics. Enables self-debugging of fatal errors,
warnings, notices, and deprecation warnings.

- Parse PHP error log entries into structured data (level, message, file, line)
- Filter by severity level (error, warning, notice, deprecated, fatal, parse)
- Filter by timestamp (since)
- Free-text search in messages
- Efficient tail implementation for large log files
- Normalizes PHP error levels to standard terms

Enables the agent to diagnose PHP-level issues and file issues in the
appropriate plugin/theme repo.
@chubes4 chubes4 merged commit 429edbc into Extra-Chill:main Mar 9, 2026
3 checks passed
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.

2 participants