Skip to content

Shows and updates the contents of your php error log files in the browser. Groups similar errors.

Notifications You must be signed in to change notification settings

lbergelt/php-error-log-viewer

 
 

Repository files navigation

PHP Error Log Viewer

PHP Tests

A GUI for your php log files which groups similar errors. Written in PHP and Vue.js.

  • Reads the specified log file and automatically shows you new errors when they appear.
  • Groups errors with similar text. This is far from perfect and just works with the (default) log-format like:
    [12-Jun-2030 12:58:55] PHP Notice: ...
  • Can be configured so clicking on an error will directly bring you to the mentioned file and line in vscode (more below).
  • Requires > PHP 7.4

Disclaimer

  • This contains code for deleting your log-file.
  • Might be heavy for you server for large log files (regexp-parsing).
  • It is meant for development-environments.
  • Created for log-files in the format [31-Mar-2021 14:25:56 UTC] PHP Notice: ... (nginx logs are currently not supported).
  • There is still room for improvement (especially where the log-file is parsed).
  • It does not work offline, as we rely on cdns to load dependencies like vue.

Getting Started

Just copy the folder next to your debug.log.

or

composer require-dev schuhwerk/php-error-log-viewer

Usage

Open the folder in your browser (like http:https://mydomain.local/php-error-log-viewer) Screenshot of the viewer interface

Settings

You can specify settings in a file named 'php-error-log-viewer.ini' in the same folder (or for composer in the grandparent folder).

;path the the log file. relative to the viewer file.
file_path='../../app/debug.log'
;toggle the linking feature
vscode_links=true
;when you run a virtual machine for development your server path might diverge from your loacal path. this is server.
vscode_path_search='/srv/www/current/'
;
vscode_path_replace='C:/my-repository/'

Linking

The log viewer extracts paths and line numbers from your log file (transforms them) and creates vscode links. This works for the following samples:

  • /srv/www/web/app/themes/defaultspace/functions.php(605): get_post_card(Object(WP_Post), Array)
  • PHP Fatal error: Uncaught TypeError: ..., called in C:\foo\bar/themes/defaultspace/functions.php on line 605
  • ... and defined in C:\foo\bar/themes/defaultspace/functions.php:63
  • ✨Tip: Use this (php) snippet in vscode (and enjoy the links):
    "Log to error log": {
      	"prefix": "error_log",
      	"body": [
      		"error_log( \"$1\" . __FILE__ . ' on line ' . __LINE__ . \"\\n\" . print_r( $2, true ) );",
      		"$4"
      	],
      	"description": "Log array/object to error log."
      }

Ideas

  • This was a single-file gui. As it went bigger we separated files (to improve readability). There could be a build-step which brings things back to a single file (like adminer uses).
  • Update to vue3
  • Use vuetify instead vue-material.
  • Make offline useable.
  • Find a way to keep stack-traces together (while sorting)

About

Shows and updates the contents of your php error log files in the browser. Groups similar errors.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • PHP 60.1%
  • HTML 39.9%