spudly.shuoink.com

the best way to predict the future is to implement it

Entries Comments


PHP Error Log Parser

17 February, 2008 (08:15) | PHP

So about a month ago I got pretty tired of looking at this:

[17-Feb-2008 07:33:52] PHP Parse error:  syntax error, unexpected T_FUNCTION, expecting ‘(’ in C:\www\forms\validate.php on line 10
[17-Feb-2008 07:33:54] PHP Parse error:  syntax error, unexpected T_FUNCTION, expecting ‘(’ in C:\www\forms\validate.php on line 10
[17-Feb-2008 07:34:08] PHP Fatal error:  Call to undefined function send_email() in C:\www\forms\email.php on line 32
[17-Feb-2008 07:34:39] PHP Parse error:  syntax error, unexpected T_STRING, expecting T_FUNCTION in C:\www\lib\User.php on line 379
[17-Feb-2008 07:34:55] PHP Parse error:  syntax error, unexpected $end in C:\www\login\login.php on line 134

The PHP error log (or any error log for that matter) is really hard on the eyes. So, I decided to write an error log parser that would make things a little prettier. And here it is:

Error Log Parser Error Log Parser - Source View

Features:

  • Displays last $n errors (specified by user)
  • Filter errors by regex
  • PHP Built-In Function names link directly to their documentation on php.net
  • Line numbers and script names are clickable. Click the line number to view the source code for the offending code. The code will be displayed, with the selected line highlighted.
  • Errors grouped by request

The parser is actually separated into 4 files.

  • errors.php - the actual parser
  • errors.html.php - the ‘normal view’ template
  • errors.source.html.php - the ’source code view’ template
  • errors.css - the css for the above templates

Also, it is currently setup to use the template engine I uploaded a few days ago. If you don’t like that, it’s pretty easy to change. If you know your way around php (which I expect you do if you’re looking at the error logs), you can manipulate the parser and templates to work without my engine in about 5 mins.

Also, you can forego the templates completely and use the parser for your own purposes. Whatever you want.

Enjoy!

Download Now

« Steal These Buttons! - CSS Sprite Style

 Using the XML DOM Without Writing 15,0000 Lines of Code »

Comments

Pingback from PHP Error Log Parser
Time: February 17, 2008, 9:46 pm

[...] poppa wrote an interesting post today onHere’s a quick excerptIf you know your way around php (which I expect you do if you’re looking at the error logs), you can manipulate the parser and templates to work without my engine in about 5 mins. Also, you can forego the templates completely and use … [...]

Comment from Tyson
Time: April 30, 2008, 4:05 pm

That is an awesome tool. But I keep getting ” Undefined offset: 1 /srv/www/html/errors/errors.php, line 132″ errors populating my error log. Any thoughts on how I can resolve this? Other than changing how my site does error reporting?

Comment from spudly
Time: April 30, 2008, 6:00 pm

try changing the code on line 132 of errors.php from

$script = isset($script) ? trim( $script[1] ) : null;

to

$script = (isset($script) && count($script) > 1) ? trim( $script[1] ) : null;

Let me know if that works.

Comment from Tyson
Time: May 1, 2008, 2:29 pm

Thanks, that did it!

Write a comment