PHP Classes
elePHPant
Icontem

bib_errors: Log and process errors of PHP scripts

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2006-07-04 (10 years ago) RSS 2.0 feedStarStarStar 59%Total: 1,495 This week: 1All time: 2,530 This week: 1,047Up
Version License Categories
bib_errors 1.0FreewareDebug, Logging
Description Author

This class can be used to intercept runtime errors of PHP scripts.

It registers a PHP error handler function that outputs the details about the errors to a given log file.

The errors may also be displayed as part of the current script output or sent by a given e-mail address to let the site administration or developer react promptly.

Now has been update to be compatible with PHP5 and the new variables declaration.

Picture of Fabrizio Parrella
Name: Fabrizio Parrella <contact>
Classes: 8 packages by
Country: United States United States
Innovation award
Innovation award
Nominee: 2x

Details
to use the class, just include the file in your script. You can declare few variables or change the variables in the file:

$_cfg['admin_email']    //this address will receive the email (default is the server_admin)
$_cfg['code']           //a code that you assign to the website (default is the server_name)
$_cfg['show_errors']    //if show the errors on the page or not (default from php.ini)
$_cfg['log_errors']     //if you want or not log the errors (this will overwrite php.ini- default from php.ini)
$_cfg['error_log']      //where the logfile is (this will overwrite php.ini - default from php.ini)
$_cfg['email_errors']   //if you want to receive an email for each error

you can also define a function that you want to user to log errors in a database or something else this function is called ONLY if log_errors = 1 leave it empty if you do not have any LOG functions.
the class will be called passing some 3 parameters:
 - $error_text = text of the error
 - $type='notice' or 'warning' or 'error'

in this case I pass a function that is in the $bibivu class, called 'write_log' previously declared.

$f_error_log = array($bibivu,'write_log');   //$bibivu->write_log($test,$type);

you can also pass a normal function, example, to call the function "write_log" that is not into a class:
$f_error_log = 'write_log';

this is an example of configuration (that is also the default used in the class):

if(!isset($_cfg['admin_email']))	$_cfg['admin_email']	= $_SERVER['SERVER_ADMIN'];		//this address will receive a copy of the email
if(!isset($_cfg['code']))			$_cfg['code']			= $_SERVER['SERVER_NAME'];
if(!isset($_cfg['show_errors']))	$_cfg['show_errors']	= ini_get('display_errors');	//if show the errors on the page or not
if(!isset($_cfg['log_errors']))		$_cfg['log_errors']		= ini_get('log_errors');		//if log the errors in a file or not
if(!isset($_cfg['error_log']))		$_cfg['error_log']		= ini_get('error_log');			//file log
//if(!isset($_cfg['error_log']))		$_cfg['error_log']		= $_SERVER['DOCUMENT_ROOT'].'/error.log';		//file log
if(!isset($_cfg['email_errors']))	$_cfg['email_errors']	= '1';
Screenshots  
  • class_clip.jpg
  Files folder image Files  
File Role Description
Files folder imagephp4x (1 file)
Files folder imagephp5x (1 file)
Accessible without login Plain text file example.php Example example script
Accessible without login Plain text file readme.txt Doc. READ ME
Plain text file _class_bib_errors.php Class main Class

  Files folder image Files  /  php4x  
File Role Description
  Accessible without login Plain text file _class_bib_errors.php Conf. variables for the class for php4

  Files folder image Files  /  php5x  
File Role Description
  Accessible without login Plain text file _class_bib_errors.php Conf. variables for the class for php5

 Version Control Unique User Downloads Download Rankings  
 0%
Total:1,495
This week:1
All time:2,530
This week:1,047Up
 User Ratings  
 
 All time
Utility:75%StarStarStarStar
Consistency:68%StarStarStarStar
Documentation:75%StarStarStarStar
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1229