DB error log
authorTim Starling <tstarling@users.mediawiki.org>
Tue, 29 Jun 2004 07:09:00 +0000 (07:09 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Tue, 29 Jun 2004 07:09:00 +0000 (07:09 +0000)
includes/Database.php
includes/DefaultSettings.php
includes/GlobalFunctions.php

index f382485..080d372 100644 (file)
@@ -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" .
index 61b71af..ac993c7 100644 (file)
@@ -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
index dd5197d..0ae7fdc 100644 (file)
@@ -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;