Changeset 889

Show
Ignore:
Timestamp:
08/31/07 18:39:44 (1 year ago)
Author:
mikey
Message:

added logging to exception handler

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/util/stubExceptionHandler.php

    r879 r889  
    2525     */ 
    2626    protected static $request; 
     27    /** 
     28     * access to session instance 
     29     * 
     30     * @var  stubSession 
     31     */ 
     32    protected static $session; 
    2733    /** 
    2834     * access to response instance 
     
    6571            self::$response->replaceData(file_get_contents(stubConfig::getConfigPath() . '/errors/500.html')); 
    6672        } 
    67  
     73         
     74        if (null !== self::$session) { 
     75            stubClassLoader::load('net.stubbles.util.log.log'); 
     76            $logData = stubLogDataFactory::create(self::$session, 'exceptions', stubLogger::LEVEL_ERROR); 
     77            $logData->addData(($exception instanceof stubThrowable) ? ($exception->getClassName()) : (get_class($exception))); 
     78            $logData->addData($exception->getMessage()); 
     79            $logData->addData($exception->getFile()); 
     80            $logData->addData($exception->getLine()); 
     81            if ($exception instanceof stubChainedException) { 
     82                $cause = $exception->getCause(); 
     83                $logData->addData(($cause instanceof stubThrowable) ? ($cause->getClassName()) : (get_class($cause))); 
     84                $logData->addData($cause->getMessage()); 
     85                $logData->addData($cause->getFile()); 
     86                $logData->addData($cause->getLine()); 
     87            } else { 
     88                $logData->addData(''); 
     89                $logData->addData(''); 
     90                $logData->addData(''); 
     91                $logData->addData(''); 
     92            } 
     93             
     94            stubLogger::logToAll($logData); 
     95        } 
     96         
    6897        // send the response because the request will end right after this 
    6998        // method has been finished 
     
    82111        self::register(); 
    83112        self::$request  = $request; 
     113        self::$$session = $session; 
    84114        self::$response = $response; 
    85115    }