IAlex has uploaded a new change for review.
https://gerrit.wikimedia.org/r/120355
Change subject: Automatically add a new line at the end of wfLogDBError()
......................................................................
Automatically add a new line at the end of wfLogDBError()
I found two calls to wfLogDBError() that do not add a new line
at the end of the message. So instead of adding them to that
entries, I changed wfLogDBError() to automatically put it on
icoming messages; as for wfDebugLog().
Change-Id: Id014b5827a0aeef6873ebf08d78f0a3d7581d63b
---
M includes/GlobalFunctions.php
M includes/db/Database.php
M includes/db/DatabaseMysqlBase.php
M includes/db/LoadBalancer.php
4 files changed, 7 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/55/120355/1
diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index a6f936f..981a556 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -1109,7 +1109,7 @@
$date = $d->format( 'D M j G:i:s T Y' );
- $text = "$date\t$host\t$wiki\t$text";
+ $text = "$date\t$host\t$wiki\t" . trim( $text ) . "\n";
wfErrorLog( $text, $wgDBerrorLog );
}
}
diff --git a/includes/db/Database.php b/includes/db/Database.php
index 91ab0ca..b811bfc 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -1109,7 +1109,7 @@
$elapsed = round( microtime( true ) -
$wgRequestTime, 3 );
if ( $elapsed < 300 ) {
# Not a database error to lose a
transaction after a minute or two
- wfLogDBError( "Connection lost and
reconnected after {$elapsed}s, query: $sqlx\n" );
+ wfLogDBError( "Connection lost and
reconnected after {$elapsed}s, query: $sqlx" );
}
if ( !$hadTrx ) {
# Should be safe to silently retry
@@ -1153,7 +1153,7 @@
$this->ignoreErrors( $ignore );
} else {
$sql1line = mb_substr( str_replace( "\n", "\\n", $sql
), 0, 5 * 1024 );
- wfLogDBError(
"$fname\t{$this->mServer}\t$errno\t$error\t$sql1line\n" );
+ wfLogDBError(
"$fname\t{$this->mServer}\t$errno\t$error\t$sql1line" );
wfDebug( "SQL ERROR: " . $error . "\n" );
throw new DBQueryError( $this, $error, $errno, $sql,
$fname );
}
diff --git a/includes/db/DatabaseMysqlBase.php
b/includes/db/DatabaseMysqlBase.php
index 85be31c..7ee03e0 100644
--- a/includes/db/DatabaseMysqlBase.php
+++ b/includes/db/DatabaseMysqlBase.php
@@ -93,7 +93,7 @@
if ( !$error ) {
$error = $this->lastError();
}
- wfLogDBError( "Error connecting to {$this->mServer}:
$error\n" );
+ wfLogDBError( "Error connecting to {$this->mServer}:
$error" );
wfDebug( "DB connection error\n" .
"Server: $server, User: $user, Password: " .
substr( $password, 0, 3 ) . "..., error: " .
$error . "\n" );
@@ -108,7 +108,7 @@
$success = $this->selectDB( $dbName );
wfRestoreWarnings();
if ( !$success ) {
- wfLogDBError( "Error selecting database $dbName
on server {$this->mServer}\n" );
+ wfLogDBError( "Error selecting database $dbName
on server {$this->mServer}" );
wfDebug( "Error selecting database $dbName on
server {$this->mServer} " .
"from client host " . wfHostname() .
"\n" );
diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php
index de4c2f5..a1703f0 100644
--- a/includes/db/LoadBalancer.php
+++ b/includes/db/LoadBalancer.php
@@ -744,13 +744,13 @@
if ( !is_object( $conn ) ) {
// No last connection, probably due to all servers
being too busy
- wfLogDBError( "LB failure with no last connection.
Connection error: {$this->mLastError}\n" );
+ wfLogDBError( "LB failure with no last connection.
Connection error: {$this->mLastError}" );
// If all servers were busy, mLastError will contain
something sensible
throw new DBConnectionError( null, $this->mLastError );
} else {
$server = $conn->getProperty( 'mServer' );
- wfLogDBError( "Connection error: {$this->mLastError}
({$server})\n" );
+ wfLogDBError( "Connection error: {$this->mLastError}
({$server})" );
$conn->reportConnectionError( "{$this->mLastError}
({$server})" ); // throws DBConnectionError
}
--
To view, visit https://gerrit.wikimedia.org/r/120355
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id014b5827a0aeef6873ebf08d78f0a3d7581d63b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: IAlex <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits