-
Notifications
You must be signed in to change notification settings - Fork 39
Log to file #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Log to file #84
Conversation
- use include pattern instead of rendering in class
- download zip file including logs and information about setup
- added utility classes
…task/logging-troubleshooting
There was a problem hiding this 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 adds logging and diagnostics capabilities to help troubleshoot customer issues. It introduces a file-based logger with automatic rotation at 2MB, a diagnostics export feature that bundles logs and system information into a downloadable zip file, and sets API request timeouts (120s total, 8s connect) to prevent indefinite hanging.
Changes:
- Introduced
Tiny_Loggersingleton for file-based logging with 2MB rotation - Added
Tiny_Diagnosticsclass to collect system info and generate downloadable diagnostics zip files - Integrated logging calls throughout the compression workflow
- Added settings UI for enabling/disabling logging and downloading diagnostics
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| tiny-compress-images.php | Added requires for new logger and diagnostics classes |
| test/unit/TinySettingsAjaxTest.php | Refactored test to use new assertHook helper method |
| test/unit/TinySettingsAdminTest.php | Added test for new logging_enabled setting registration |
| test/unit/TinyLoggerTest.php | Added comprehensive tests for logger singleton, file creation, rotation, and enable/disable behavior |
| test/unit/TinyDiagnosticsTest.php | Added tests for diagnostics action hook and info collection |
| test/helpers/wordpress.php | Added assertHook helper, WordPressMocks class with mock WordPress functions, and formatting updates |
| src/views/settings.php | Included new diagnostics settings partial |
| src/views/settings-diagnostics.php | New view for logging toggle and diagnostics download button |
| src/js/admin.js | Added AJAX handler for diagnostics download |
| src/css/admin.css | Added utility classes for diagnostics UI |
| src/class-tiny-settings.php | Instantiated diagnostics and registered logging_enabled setting |
| src/class-tiny-plugin.php | Initialized logger and added debug logging throughout compression flow |
| src/class-tiny-logger.php | New singleton logger with file rotation and WordPress option integration |
| src/class-tiny-image.php | Added detailed debug and error logging for compression operations |
| src/class-tiny-diagnostics.php | New class for collecting and exporting diagnostic information |
| src/class-tiny-compress-fopen.php | Added debug logging for fopen compression responses |
| src/class-tiny-compress-client.php | Added timeout constants, error logging, and applied timeout settings to client |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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)
We had two customers reporting two different issues which we could not figure out. Often times this is due to setup configurations but it is hard to figure out.
Having some diagnostics and logs should make it easier to troubleshoot these issues.
This PR will also:
Good to know
Screenshots

Customers can turn on logging and download a diagnostics zip file from within settings