X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fdebug%2Flogger%2FLegacyLogger.php;h=526b4ab03b8888315608691f195143238e8cfd3e;hp=65719fa5742bd484e0c7af316106870a9063655b;hb=e3bd13db0c285f312e31bb1b7271af4628cca80c;hpb=41b5aa343f26a45244ae84d509bec797bf6aa48e diff --git a/includes/debug/logger/LegacyLogger.php b/includes/debug/logger/LegacyLogger.php index 65719fa574..526b4ab03b 100644 --- a/includes/debug/logger/LegacyLogger.php +++ b/includes/debug/logger/LegacyLogger.php @@ -59,7 +59,7 @@ class LegacyLogger extends AbstractLogger { * * @var array $levelMapping */ - protected static $levelMapping = array( + protected static $levelMapping = [ LogLevel::DEBUG => 100, LogLevel::INFO => 200, LogLevel::NOTICE => 250, @@ -68,8 +68,7 @@ class LegacyLogger extends AbstractLogger { LogLevel::CRITICAL => 500, LogLevel::ALERT => 550, LogLevel::EMERGENCY => 600, - ); - + ]; /** * @param string $channel @@ -85,17 +84,18 @@ class LegacyLogger extends AbstractLogger { * @param string $message * @param array $context */ - public function log( $level, $message, array $context = array() ) { + public function log( $level, $message, array $context = [] ) { if ( self::shouldEmit( $this->channel, $message, $level, $context ) ) { $text = self::format( $this->channel, $message, $context ); $destination = self::destination( $this->channel, $message, $context ); self::emit( $text, $destination ); } - // Add to debug toolbar - MWDebug::debugMsg( $message, array( 'channel' => $this->channel ) + $context ); + if ( !isset( $context['private'] ) || !$context['private'] ) { + // Add to debug toolbar if not marked as "private" + MWDebug::debugMsg( $message, [ 'channel' => $this->channel ] + $context ); + } } - /** * Determine if the given message should be emitted or not. * @@ -118,6 +118,13 @@ class LegacyLogger extends AbstractLogger { // All messages on the wfErrorLog channel should be emitted. $shouldEmit = true; + } elseif ( $channel === 'wfDebug' ) { + // wfDebug messages are emitted if a catch all logging file has + // been specified. Checked explicitly so that 'private' flagged + // messages are not discarded by unset $wgDebugLogGroups channel + // handling below. + $shouldEmit = $wgDebugLogFile != ''; + } elseif ( isset( $wgDebugLogGroups[$channel] ) ) { $logConfig = $wgDebugLogGroups[$channel]; @@ -154,7 +161,6 @@ class LegacyLogger extends AbstractLogger { return $shouldEmit; } - /** * Format a message. * @@ -239,7 +245,6 @@ class LegacyLogger extends AbstractLogger { return self::interpolate( $text, $context ); } - /** * Format a message as `wfDebug()` would have formatted it. * @@ -261,7 +266,6 @@ class LegacyLogger extends AbstractLogger { return "{$text}\n"; } - /** * Format a message as `wfLogDBError()` would have formatted it. * @@ -278,13 +282,7 @@ class LegacyLogger extends AbstractLogger { $cachedTimezone = new DateTimeZone( $wgDBerrorLogTZ ); } - // Workaround for https://bugs.php.net/bug.php?id=52063 - // Can be removed when min PHP > 5.3.6 - if ( $cachedTimezone === null ) { - $d = date_create( 'now' ); - } else { - $d = date_create( 'now', $cachedTimezone ); - } + $d = date_create( 'now', $cachedTimezone ); $date = $d->format( 'D M j G:i:s T Y' ); $host = wfHostname(); @@ -294,7 +292,6 @@ class LegacyLogger extends AbstractLogger { return $text; } - /** * Format a message as `wfDebugLog() would have formatted it. * @@ -310,7 +307,6 @@ class LegacyLogger extends AbstractLogger { return $text; } - /** * Interpolate placeholders in logging message. * @@ -320,7 +316,7 @@ class LegacyLogger extends AbstractLogger { */ public static function interpolate( $message, array $context ) { if ( strpos( $message, '{' ) !== false ) { - $replace = array(); + $replace = []; foreach ( $context as $key => $val ) { $replace['{' . $key . '}'] = self::flatten( $val ); } @@ -329,7 +325,6 @@ class LegacyLogger extends AbstractLogger { return $message; } - /** * Convert a logging context element to a string suitable for * interpolation. @@ -389,7 +384,6 @@ class LegacyLogger extends AbstractLogger { return '[Unknown ' . gettype( $item ) . ']'; } - /** * Select the appropriate log output destination for the given log event. * @@ -430,7 +424,6 @@ class LegacyLogger extends AbstractLogger { return $destination; } - /** * Log to a file without getting "file size exceeded" signals. *