private function getLevel(\Throwable $t, array $context): string
    {
        // Check if the severity matches a PSR-3 log level
        if (
            false === $this->ignoreSeverity &&
            isset($context[Context::SEVERITY]) &&
            is_string($context[Context::SEVERITY]) &&
            $this->validateLevel($context[Context::SEVERITY])
        ) {
            return $context[Context::SEVERITY];
        }

        // Find the log level based on the error in the level map (avoid looping through the whole array)
        // Note: this ignores the order defined in the map.
        $class = get_class($t);
        if (isset($this->levelMap[$class]) && $this->validateLevel($this->levelMap[$class])) {
            return $this->levelMap[$class];
        }

        // Find the log level based on the error in the level map
        foreach ($this->levelMap as $className => $candidate) {
            if ($t instanceof $className && $this->validateLevel($candidate)) {
                return $candidate;
            }
        }

        // Return the default log level
        return self::DEFAULT_LOG_LEVEL;
    }