src/Target.php
public static function filterMessages($messages, array $levels = [], array $categories = [], array $except = []): array
    {
        foreach ($messages as $i => $message) {
            if (!empty($levels) && !in_array($message[0], $levels, true)) {
                unset($messages[$i]);
                continue;
            }

            $matched = empty($categories);
            foreach ($categories as $category) {
                if ($message[2]['category'] === $category || !empty($category) && substr_compare($category, '*', -1, 1) === 0 && strpos($message[2]['category'], rtrim($category, '*')) === 0) {
                    $matched = true;
                    break;
                }
            }

            if ($matched) {
                foreach ($except as $category) {
                    $prefix = rtrim($category, '*');
                    if (($message[2]['category'] === $category || $prefix !== $category) && strpos($message[2]['category'], $prefix) === 0) {
                        $matched = false;
                        break;
                    }
                }
            }

            if (!$matched) {
                unset($messages[$i]);
            }
        }

        return $messages;
    }
public static function filterMessages($messages, array $levels = [], array $categories = [], array $except = []): array
    {
        foreach ($messages as $i => $message) {
            if (!empty($levels) && !in_array($message[0], $levels, true)) {
                unset($messages[$i]);
                continue;
            }

            $matched = empty($categories);
            foreach ($categories as $category) {
                if ($message[2]['category'] === $category || !empty($category) && substr_compare($category, '*', -1, 1) === 0 && strpos($message[2]['category'], rtrim($category, '*')) === 0) {
                    $matched = true;
                    break;
                }
            }

            if ($matched) {
                foreach ($except as $category) {
                    $prefix = rtrim($category, '*');
                    if (($message[2]['category'] === $category || $prefix !== $category) && strpos($message[2]['category'], $prefix) === 0) {
                        $matched = false;
                        break;
                    }
                }
            }

            if (!$matched) {
                unset($messages[$i]);
            }
        }

        return $messages;
    }
public static function filterMessages ( $ messages , array $ levels = [ ] , array $ categories = [ ] , array $ except = [ ] ) : array { foreach ( $ messages as $ i => $ message ) { if ( ! empty ( $ levels ) && ! in_array ( $ message [ 0 ] , $ levels , true ) ) { unset ( $ messages [ $ i ] ) ; continue ; } $ matched = empty ( $ categories ) ; foreach ( $ categories as $ category ) { if ( $ message [ 2 ] [ 'category' ] === $ category || ! empty ( $ category ) && substr_compare ( $ category , '*' , - 1 , 1 ) === 0 && strpos ( $ message [ 2 ] [ 'category' ] , rtrim ( $ category , '*' ) ) === 0 ) { $ matched = true ; break ; } } if ( $ matched ) { foreach ( $ except as $ category ) { $ prefix = rtrim ( $ category , '*' ) ; if ( ( $ message [ 2 ] [ 'category' ] === $ category || $ prefix !== $ category ) && strpos ( $ message [ 2 ] [ 'category' ] , $ prefix ) === 0 ) { $ matched = false ; break ; } } } if ( ! $ matched ) { unset ( $ messages [ $ i ] ) ; } } return $ messages ; }
Filters the given messages according to their categories and levels.
@param array $messages messages to be filtered.
The message structure follows that in [[Logger::messages]].
@param array $levels the message levels to filter by. Empty value means allowing all levels.
@param array $categories the message categories to filter by. If empty, it means all categories are allowed.
@param array $except the message categories to exclude. If empty, it means all categories are allowed.
@return array the filtered messages.
Filters the given messages according to their categories and levels .