Seldaek/monolog · error · RuntimeException

Could not preg_split: {} / {}

Error message

Could not preg_split: {} / {}

What it means

Error "Could not preg_split: {} / {}" thrown in Seldaek/monolog.

Source

Thrown at src/Monolog/Handler/SyslogUdpHandler.php:99

    {
        $this->socket->close();
    }

    /**
     * @param  string|string[] $message
     * @return string[]
     */
    private function splitMessageIntoLines($message): array
    {
        if (\is_array($message)) {
            $message = implode("\n", $message);
        }

        $lines = preg_split('/$\R?^/m', (string) $message, -1, PREG_SPLIT_NO_EMPTY);
        if (false === $lines) {
            $pcreErrorCode = preg_last_error();

            throw new \RuntimeException('Could not preg_split: ' . $pcreErrorCode . ' / ' . preg_last_error_msg());
        }

        return $lines;
    }

    /**
     * Make common syslog header (see rfc5424 or rfc3164)
     */
    protected function makeCommonSyslogHeader(int $severity, DateTimeInterface $datetime): string
    {
        $priority = $severity + $this->facility;

        $pid = getmypid();
        if (false === $pid) {
            $pid = '-';
        }

        $hostname = gethostname();

View on GitHub (pinned to 57eb102834)

When it happens

Trigger: Thrown at src/Monolog/Handler/SyslogUdpHandler.php:99 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Seldaek/monolog@57eb102834 (2026-08-17). Data as JSON: /api/errors/466342cab4a2fdba. Report an issue: GitHub.