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;
/**
$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
$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'] ) ) {
$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;
*/
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;
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() . ']';
}