Login   Register  
PHP Classes
elePHPant
Icontem

File: ErrorHandler.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Wouter van Vliet  >  Logging  >  ErrorHandler.php  >  Download  
File: ErrorHandler.php
Role: Application script
Content type: text/plain
Description: Custom error handler, uses the Logging class
Class: Logging
Logging errors and notices to files or Web pages
Author: By
Last change:
Date: 2003-08-18 19:04
Size: 811 bytes
 

Contents

Class file image Download
<?php
# Function for errorHandling
function logging_ErrorHandler ($Code$String$File$Line) {
    global 
$Log;

    
$ErrorString '['.$File.' (Line '.$Line.')] '.$String;

    switch(
$Code) {
        case 
0:
            
# Call was preceeded with a @ sign.. not sure what to do..
            
$OLT $Log->setLogType(L_STDERR);
            if (
$OLT != L_STDERR) {
                
$Log->Notice('{@} '.$ErrorString);
            }
            
$Log->setLogType($OLT);

            break;
        case 
E_ERROR:
        case 
E_USER_ERROR:
            
$Log->Error($ErrorString);
            break;
        case 
E_WARNING:
            
$Log->Warning($ErrorString);
            break;
        case 
E_PARSE:
            
$Log->Fatal($ErrorString);
            break;
        case 
E_NOTICE:
            
$Log->Notice($ErrorString);
            break;
        default:
            
$Log->_doWrite('PHP ERROR: '.$Code$ErrorString);
    };

}
set_error_handler("logging_ErrorHandler");
?>