X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fdebug%2Flogger%2FLegacyLogger.php;h=bbcd33ac753895e646709d8cc41551b513cec2b5;hb=5196ac32c6;hp=9d0789c4dc1d64b56fbe5f4627d56e5eb2497d29;hpb=578318e68856ef2f5258c67a50d815d06960e206;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/debug/logger/LegacyLogger.php b/includes/debug/logger/LegacyLogger.php index 9d0789c4dc..bbcd33ac75 100644 --- a/includes/debug/logger/LegacyLogger.php +++ b/includes/debug/logger/LegacyLogger.php @@ -22,6 +22,7 @@ namespace MediaWiki\Logger; use DateTimeZone; use Exception; +use WikiMap; use MWDebug; use MWExceptionHandler; use Psr\Log\AbstractLogger; @@ -93,18 +94,38 @@ class LegacyLogger extends AbstractLogger { * @return null */ public function log( $level, $message, array $context = [] ) { + global $wgDBerrorLog; + if ( is_string( $level ) ) { $level = self::$levelMapping[$level]; } - if ( $this->channel === 'DBQuery' && isset( $context['method'] ) - && isset( $context['master'] ) && isset( $context['runtime'] ) + if ( $this->channel === 'DBQuery' + && isset( $context['method'] ) + && isset( $context['master'] ) + && isset( $context['runtime'] ) ) { - MWDebug::query( $message, $context['method'], $context['master'], $context['runtime'] ); - return; // only send profiling data to MWDebug profiling + // Also give the query information to the MWDebug tools + $enabled = MWDebug::query( + $message, + $context['method'], + $context['master'], + $context['runtime'] + ); + if ( $enabled ) { + // If we the toolbar was enabled, return early so that we don't + // also log the query to the main debug output. + return; + } } + // If this is a DB-related error, and the site has $wgDBerrorLog + // configured, rewrite the channel as wfLogDBError instead. + // Likewise, if the site does not use $wgDBerrorLog, it should + // configurable like any other channel via $wgDebugLogGroups + // or $wgMWLoggerDefaultSpi. if ( isset( self::$dbChannels[$this->channel] ) && $level >= self::$levelMapping[LogLevel::ERROR] + && $wgDBerrorLog ) { // Format and write DB errors to the legacy locations $effectiveChannel = 'wfLogDBError'; @@ -306,7 +327,7 @@ class LegacyLogger extends AbstractLogger { $date = $d->format( 'D M j G:i:s T Y' ); $host = wfHostname(); - $wiki = wfWikiID(); + $wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ); $text = "{$date}\t{$host}\t{$wiki}\t{$message}\n"; return $text; @@ -322,7 +343,7 @@ class LegacyLogger extends AbstractLogger { */ protected static function formatAsWfDebugLog( $channel, $message, $context ) { $time = wfTimestamp( TS_DB ); - $wiki = wfWikiID(); + $wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ); $host = wfHostname(); $text = "{$time} {$host} {$wiki}: {$message}\n"; return $text; @@ -354,7 +375,7 @@ class LegacyLogger extends AbstractLogger { * @return string */ protected static function flatten( $item ) { - if ( null === $item ) { + if ( $item === null ) { return '[Null]'; }