From 524d56a6f160f487d61cc26153db15493f99f308 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 29 Jun 2004 07:09:00 +0000 Subject: [PATCH] DB error log --- includes/Database.php | 2 ++ includes/DefaultSettings.php | 1 + includes/GlobalFunctions.php | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/includes/Database.php b/includes/Database.php index f382485813..080d372387 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -185,6 +185,8 @@ class Database { if( $this->mIgnoreErrors ) { wfDebug("SQL ERROR (ignored): " . $error . "\n"); } else { + $sql1line = str_replace( "\n", "\\n", $sql ); + wfLogDBError("$errno\t$error\t$sql1line\n"); wfDebug("SQL ERROR: " . $error . "\n"); if ( $wgCommandLineMode ) { wfDebugDieBacktrace( "A database error has occurred\n" . diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 61b71afcde..ac993c7a49 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -70,6 +70,7 @@ $wgDBsqluser = 'sqluser'; $wgDBsqlpassword = 'sqlpass'; $wgDBpassword = 'userpass'; $wgSqlLogFile = "{$wgUploadDirectory}/sqllog_mFhyRe6"; +$wgDBerrorLog = false; # File to log MySQL errors to $wgDBminWordLen = 4; $wgDBtransactions = false; # Set to true if using InnoDB tables diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index dd5197d07d..0ae7fdcbe4 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -227,6 +227,15 @@ function wfDebug( $text, $logonly = false ) } } +# Log for database errors +function wfLogDBError( $text ) { + global $wgDBerrorLog; + if ( $wgDBerrorLog ) { + $text = date("D M j G:i:s T Y") . "\t$text"; + error_log( $text, 3, $wgDBerrorLog ); + } +} + function logProfilingData() { global $wgRequestTime, $wgDebugLogFile; -- 2.20.1