Skip to content

Comments

feat: add diagnostic logging and troubleshooting tools#95

Closed
tijmenbruggeman wants to merge 5 commits intotinify:masterfrom
wcreateweb:task/diagnostic-logging
Closed

feat: add diagnostic logging and troubleshooting tools#95
tijmenbruggeman wants to merge 5 commits intotinify:masterfrom
wcreateweb:task/diagnostic-logging

Conversation

@tijmenbruggeman
Copy link
Collaborator

This PR adds diagnostic logging functionality and troubleshooting tools to help debug issues in production environments.

Changes

  • Adds Tiny_Logger singleton class for centralized logging
  • Implements log rotation with 2MB file size limit
  • Adds Tiny_Diagnostics class to collect system information
  • Provides downloadable diagnostics zip file with:
    • System and server information
    • Active plugins and theme details
    • Tinify settings and image sizes
    • Log files
  • Adds settings UI for enabling/disabling logging
  • Includes comprehensive unit tests for both logger and diagnostics

Key Features

  • Logs are stored in wp-content/uploads/tiny-compress-logs/
  • Automatic log rotation when exceeding 2MB
  • Logs are cleared when toggling logging from off to on
  • AJAX endpoint for secure diagnostics download with nonce verification
  • Uses WP_Filesystem API for secure file operations

Sreini and others added 5 commits February 16, 2026 07:34
* chore: add settings view

- use include pattern instead of rendering in class

* chore: add logger singleton

* chore: add diagnostics class

- download zip file including logs and information about setup

* chore: download zip file from settings page

* chore: add loader and improve markup

- added utility classes

* Add various log points

* Set timeout and proxy options on curl client

* Scaffold tests

* formatting

* Add initial tests

* On constructor log enabled test

* Manual formatting logger

* Manual formatting fixes in diagnostics

* chore: add tests for log path

* chore: simplify rotation

* Format

* change file name, format and size

* Clear logs when turned on

* Add more tests

* Add mocks for test

* set timeout to 300

* Seperate API timeout and connect timeout

* remove server info and add a phpinfo file

* test: add nonce verification test for download_diagnostics

Add comprehensive test for nonce verification in the download_diagnostics
AJAX endpoint. The test verifies that check_ajax_referer is called with the
correct parameters and that wp_die is invoked when nonce verification fails.

Also:
- Add check_ajax_referer and wp_die mock implementations to WordPress test helpers
- Add wp_json_encode mock for test compatibility
- Rename test file to match class name convention (Tiny_Diagnostics_Test.php)

* Replace phpinfo with server info block

* Use temp path and remove cleanup

* Check permissions

* Use WP_Filesystem instead of low level php file handlers

* formatting

* Fix indentation

* Fix test locale

* Fix docs in mocks

* Add docs for connection timeout

* Add docs for reason api timeout

* Add docs

* Remove headers from log to prevent senstive data being logged in fopen client

* format

* move access to admin

* update test for manage options

* make clear_logs static

* Use error_log for logging to file

* format
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