From bcb9f9e1c0dda36bfe2096e92de0ad77e21b38f8 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 2 Aug 2006 17:40:09 +0000 Subject: [PATCH] Log exceptions --- includes/Database.php | 10 ++++++++++ includes/Exception.php | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/includes/Database.php b/includes/Database.php index 1812cd1ec3..1acb83cd35 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -86,6 +86,11 @@ class DBConnectionError extends DBError { return $this->getMessage() . "\n"; } + function getLogMessage() { + # Don't send to the exception log + return false; + } + function getPageTitle() { global $wgSitename; return "$wgSitename has a problem"; @@ -205,6 +210,11 @@ class DBQueryError extends DBError { } } + function getLogMessage() { + # Don't send to the exception log + return false; + } + function getPageTitle() { return $this->msg( 'databaseerror', 'Database error' ); } diff --git a/includes/Exception.php b/includes/Exception.php index 027c5d3350..696454d052 100644 --- a/includes/Exception.php +++ b/includes/Exception.php @@ -41,6 +41,13 @@ class MWException extends Exception } } + function getLogMessage() { + $file = $this->getFile(); + $line = $this->getLine(); + $message = $this->getMessage(); + return "{$_SERVER['REQUEST_URI']} Exception from line $line of $file: $message"; + } + function reportHTML() { global $wgOut; if ( $this->useOutputPage() ) { @@ -68,6 +75,10 @@ class MWException extends Exception if ( $wgCommandLineMode ) { $this->reportText(); } else { + $log = $this->getLogMessage(); + if ( $log ) { + wfDebugLog( 'exception', $log ); + } $this->reportHTML(); } } @@ -95,6 +106,7 @@ class MWException extends Exception function htmlFooter() { echo ""; } + } /** -- 2.20.1