From c332fe2e87208bd73e4b329c1d243c8dfbf46603 Mon Sep 17 00:00:00 2001 From: janis steiner Date: Wed, 6 May 2026 12:48:33 +0200 Subject: [PATCH] adding syslog --- src/Worker/SocketListener.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Worker/SocketListener.php b/src/Worker/SocketListener.php index c4df333..6ebcfac 100644 --- a/src/Worker/SocketListener.php +++ b/src/Worker/SocketListener.php @@ -110,6 +110,7 @@ class SocketListener foreach ($lines as $line) { $line = rtrim($line, "\r\n"); if ($line !== '') { + $line = preg_replace('/^\<\d+\>/', '', $line); ($this->onLine)($line, $id); } } @@ -126,15 +127,22 @@ class SocketListener if ($data === false) { return; } + fprintf(STDERR, "UDP recv %d bytes from %s:%d\n", strlen($buf), $from, $port); $lines = explode("\n", rtrim($buf, "\r\n")); foreach ($lines as $line) { $line = rtrim($line, "\r\n"); if ($line !== '') { - ($this->onLine)($line, $id); + $this->handleLineWithSyslog($line, $id); } } } + private function handleLineWithSyslog(string $line, int $sourceId): void + { + $line = preg_replace('/^\<\d+\>/', '', $line); + ($this->onLine)($line, $sourceId); + } + public function stop(): void { foreach ($this->tcpClients as $id => $clients) {