X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fdebug%2Flogger%2FLegacyLogger.php;h=974b044bebf8b51a5658706193edba1f88d2d9c9;hp=9f63eded097c731c02ad8c109826f63b41922aa0;hb=88e3a888cc6823f11df79ac53eb963a7e4d2871a;hpb=f2d4db9d03a984d998db9044e63e548597511eb6 diff --git a/includes/debug/logger/LegacyLogger.php b/includes/debug/logger/LegacyLogger.php index 9f63eded09..974b044beb 100644 --- a/includes/debug/logger/LegacyLogger.php +++ b/includes/debug/logger/LegacyLogger.php @@ -21,12 +21,14 @@ namespace MediaWiki\Logger; use DateTimeZone; +use Error; use Exception; use WikiMap; use MWDebug; use MWExceptionHandler; use Psr\Log\AbstractLogger; use Psr\Log\LogLevel; +use Throwable; use UDPTransport; /** @@ -100,16 +102,15 @@ class LegacyLogger extends AbstractLogger { $level = self::$levelMapping[$level]; } if ( $this->channel === 'DBQuery' - && isset( $context['method'] ) - && isset( $context['master'] ) - && isset( $context['runtime'] ) + && $level === self::$levelMapping[LogLevel::DEBUG] + && isset( $context['sql'] ) ) { // Also give the query information to the MWDebug tools $enabled = MWDebug::query( - $message, + $context['sql'], $context['method'], - $context['master'], - $context['runtime'] + $context['runtime'], + $context['db_host'] ); if ( $enabled ) { // If we the toolbar was enabled, return early so that we don't @@ -269,7 +270,7 @@ class LegacyLogger extends AbstractLogger { $e = $context['exception']; $backtrace = false; - if ( $e instanceof Exception ) { + if ( $e instanceof Throwable || $e instanceof Exception ) { $backtrace = MWExceptionHandler::getRedactedTrace( $e ); } elseif ( is_array( $e ) && isset( $e['trace'] ) ) { @@ -327,7 +328,7 @@ class LegacyLogger extends AbstractLogger { $date = $d->format( 'D M j G:i:s T Y' ); $host = wfHostname(); - $wiki = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() ); + $wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ); $text = "{$date}\t{$host}\t{$wiki}\t{$message}\n"; return $text; @@ -343,7 +344,7 @@ class LegacyLogger extends AbstractLogger { */ protected static function formatAsWfDebugLog( $channel, $message, $context ) { $time = wfTimestamp( TS_DB ); - $wiki = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() ); + $wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ); $host = wfHostname(); $text = "{$time} {$host} {$wiki}: {$message}\n"; return $text; @@ -405,8 +406,9 @@ class LegacyLogger extends AbstractLogger { return $item->format( 'c' ); } - if ( $item instanceof Exception ) { - return '[Exception ' . get_class( $item ) . '( ' . + if ( $item instanceof Throwable || $item instanceof Exception ) { + $which = $item instanceof Error ? 'Error' : 'Exception'; + return '[' . $which . ' ' . get_class( $item ) . '( ' . $item->getFile() . ':' . $item->getLine() . ') ' . $item->getMessage() . ']'; }