X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdebug%2Flogger%2FLegacyLogger.php;h=4614c46b6d27af03b4d6e4f2427005862481aaff;hb=64b83bdb3afd0ee4f8fc1893a865409c198e601e;hp=3318ceb03760339979a379a6c5fcd22045dfdc15;hpb=09110719680d7a0646a454ff1b2633a042952003;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/debug/logger/LegacyLogger.php b/includes/debug/logger/LegacyLogger.php index 3318ceb037..6359509088 100644 --- a/includes/debug/logger/LegacyLogger.php +++ b/includes/debug/logger/LegacyLogger.php @@ -43,8 +43,7 @@ use UDPTransport; * * @see \MediaWiki\Logger\LoggerFactory * @since 1.25 - * @author Bryan Davis - * @copyright © 2014 Bryan Davis and Wikimedia Foundation. + * @copyright © 2014 Wikimedia Foundation and contributors */ class LegacyLogger extends AbstractLogger { @@ -94,6 +93,9 @@ class LegacyLogger extends AbstractLogger { * @return null */ public function log( $level, $message, array $context = [] ) { + if ( is_string( $level ) ) { + $level = self::$levelMapping[$level]; + } if ( $this->channel === 'DBQuery' && isset( $context['method'] ) && isset( $context['master'] ) && isset( $context['runtime'] ) ) { @@ -102,8 +104,7 @@ class LegacyLogger extends AbstractLogger { } if ( isset( self::$dbChannels[$this->channel] ) - && isset( self::$levelMapping[$level] ) - && self::$levelMapping[$level] >= LogLevel::ERROR + && $level >= self::$levelMapping[LogLevel::ERROR] ) { // Format and write DB errors to the legacy locations $effectiveChannel = 'wfLogDBError'; @@ -127,7 +128,7 @@ class LegacyLogger extends AbstractLogger { * * @param string $channel * @param string $message - * @param string|int $level \Psr\Log\LogEvent constant or Monlog level int + * @param string|int $level \Psr\Log\LogEvent constant or Monolog level int * @param array $context * @return bool True if message should be sent to disk/network, false * otherwise @@ -135,6 +136,10 @@ class LegacyLogger extends AbstractLogger { public static function shouldEmit( $channel, $message, $level, $context ) { global $wgDebugLogFile, $wgDBerrorLog, $wgDebugLogGroups; + if ( is_string( $level ) ) { + $level = self::$levelMapping[$level]; + } + if ( $channel === 'wfLogDBError' ) { // wfLogDBError messages are emitted if a database log location is // specfied. @@ -162,9 +167,6 @@ class LegacyLogger extends AbstractLogger { } if ( isset( $logConfig['level'] ) ) { - if ( is_string( $level ) ) { - $level = self::$levelMapping[$level]; - } $shouldEmit = $level >= self::$levelMapping[$logConfig['level']]; } } else { @@ -324,7 +326,7 @@ class LegacyLogger extends AbstractLogger { * @param string $channel * @param string $message * @param array $context - * @return null + * @return string */ protected static function formatAsWfDebugLog( $channel, $message, $context ) { $time = wfTimestamp( TS_DB ); @@ -375,7 +377,7 @@ class LegacyLogger extends AbstractLogger { if ( is_nan( $item ) ) { return 'NaN'; } - return $item; + return (string)$item; } if ( is_scalar( $item ) ) {