protected function getQuotedFormatString()
    {
        // Valid pattern of log format directives
        $validPattern = '%(\!?[2-5]\d\d(\,[2-5]\d\d)*)?(\<|\>)?(\{[^\}]*\})?[a-z]';

        $pattern = preg_replace_callback(
            '/(?<before>' . $validPattern . '?)?(?<match>.+?)(?<after>' . $validPattern . ')?/i',
            function (array $matches) {
                $before = isset($matches['before']) ? $matches['before'] : '';
                $after = isset($matches['after']) ? $matches['after'] : '';
                $match = preg_quote($matches['match'], '/');

                return "{$before}{$match}{$after}";
            },
            $this->format
        );

        return $pattern;
    }