Merge "Convert Special:DeletedContributions to use OOUI."
[lhc/web/wiklou.git] / includes / debug / logger / LegacyLogger.php
index ef7a994..4614c46 100644 (file)
@@ -94,9 +94,18 @@ 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'] )
+               ) {
+                       MWDebug::query( $message, $context['method'], $context['master'], $context['runtime'] );
+                       return; // only send profiling data to MWDebug profiling
+               }
+
                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';
@@ -109,11 +118,7 @@ class LegacyLogger extends AbstractLogger {
                        $destination = self::destination( $effectiveChannel, $message, $context );
                        self::emit( $text, $destination );
                }
-               if ( $this->channel === 'DBQuery' && isset( $context['method'] )
-                       && isset( $context['master'] ) && isset( $context['runtime'] )
-               ) {
-                       MWDebug::query( $message, $context['method'], $context['master'], $context['runtime'] );
-               } elseif ( !isset( $context['private'] ) || !$context['private'] ) {
+               if ( !isset( $context['private'] ) || !$context['private'] ) {
                        // Add to debug toolbar if not marked as "private"
                        MWDebug::debugMsg( $message, [ 'channel' => $this->channel ] + $context );
                }
@@ -124,7 +129,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
@@ -132,6 +137,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.
@@ -159,9 +168,6 @@ class LegacyLogger extends AbstractLogger {
                                }
 
                                if ( isset( $logConfig['level'] ) ) {
-                                       if ( is_string( $level ) ) {
-                                               $level = self::$levelMapping[$level];
-                                       }
                                        $shouldEmit = $level >= self::$levelMapping[$logConfig['level']];
                                }
                        } else {
@@ -321,7 +327,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 );