Log PHP errors to the OC log

This commit is contained in:
Victor Dubiniuk 2012-09-12 22:30:04 +03:00
parent 9bfdf47cd4
commit bbf8bb0bb3
2 changed files with 20 additions and 0 deletions

View File

@ -317,6 +317,9 @@ class OC{
self::initPaths();
register_shutdown_function(array('OC_Log', 'onShutdown'));
set_error_handler(array('OC_Log', 'onError' ));
// set debug mode if an xdebug session is active
if (!defined('DEBUG') || !DEBUG) {
if(isset($_COOKIE['XDEBUG_SESSION'])) {

View File

@ -36,4 +36,21 @@ class OC_Log {
$log_class=self::$class;
$log_class::write($app, $message, $level);
}
//Fatal errors handler
public static function onShutdown(){
$error = error_get_last();
if($error) {
//ob_end_clean();
self::write('PHP', $error['message'] . ' at ' . $error['file'] . '#' . $error['line'], self::FATAL);
} else {
return true;
}
}
//Recoverable errors handler
public static function onError($number, $message, $file, $line){
self::write('PHP', $message . ' at ' . $file . '#' . $line, self::WARN);
}
}