<?phpset_include_path('../library'. PATH_SEPARATOR . get_include_path());require_once "Zend/Loader.php";Zend_Loader::registerAutoload();require_once "Logger.php";class exceptionContents{public function display(){try{$exception = new Exception('message passed to exception', 5);throw $exception;}catch(Exception $exception){Logger::logMessage('message passed to log object', 1, $exception);}}}$exceptionContents = new ExceptionContents();$exceptionContents->display();?>
.....which produces this sort of information in the log file........
<logEntry>
<timestamp>2008-07-30T21:10:21+01:00</timestamp>
<message>message passed to log object</message>
<priority>1</priority>
<priorityName>ALERT</priorityName>
<exceptionCode>5</exceptionCode>
<file>/path/to/file/containing/line/where/thrown/exception/was/created.php</file>
<line>16</line>
<exceptionMessage>message passed to exception</exceptionMessage>
<exceptionTrace>a:1:{i:0; a:6:{s:4:"file"; s:74:"/path/to/file/containing/method/call/that/throws/exception.php"; s:4:"line"; i:27; s:8:"function"; s:7:"display"; s:5:"class"; s:17:"exceptionContents"; s:4:"type"; s:2:"->"; s:4:"args"; a:0:{}}}</exceptionTrace>
<exceptionTraceAsString>
#0 /path/to/file/containing/method/call/that/throws/exception.php(27): exceptionContents->display()
#1 {main}
</exceptionTraceAsString>
</logEntry>
No comments:
Post a Comment