Improve connection logging a little more
authorChad Horohoe <chadh@wikimedia.org>
Wed, 1 Nov 2017 17:23:01 +0000 (10:23 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 1 Nov 2017 21:09:47 +0000 (21:09 +0000)
Don't include the trace in the actual message, that keeps us from
grouping these messages by type. Instead inject the trace as an
extra parameter we'll pick up in logstash

Change-Id: I48184c1af2560827ef50baff4fc0443f00697504

includes/libs/rdbms/database/Database.php

index a9dd074..e04566e 100644 (file)
@@ -948,9 +948,8 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                                $msg = __METHOD__ . ': lost connection to {dbserver}; reconnected';
                                $params = [ 'dbserver' => $this->getServer() ];
                                $this->connLogger->warning( $msg, $params );
-                               $this->queryLogger->warning(
-                                       "$msg:\n" . ( new RuntimeException() )->getTraceAsString(),
-                                       $params );
+                               $this->queryLogger->warning( $msg, $params +
+                                       [ 'trace' => ( new RuntimeException() )->getTraceAsString() ] );
 
                                if ( !$recoverable ) {
                                        # Callers may catch the exception and continue to use the DB