adding syslog
Deploy / deploy (push) Successful in 9s

This commit is contained in:
2026-05-06 12:48:33 +02:00
parent 60da8bc1ab
commit c332fe2e87
+9 -1
View File
@@ -110,6 +110,7 @@ class SocketListener
foreach ($lines as $line) { foreach ($lines as $line) {
$line = rtrim($line, "\r\n"); $line = rtrim($line, "\r\n");
if ($line !== '') { if ($line !== '') {
$line = preg_replace('/^\<\d+\>/', '', $line);
($this->onLine)($line, $id); ($this->onLine)($line, $id);
} }
} }
@@ -126,15 +127,22 @@ class SocketListener
if ($data === false) { if ($data === false) {
return; return;
} }
fprintf(STDERR, "UDP recv %d bytes from %s:%d\n", strlen($buf), $from, $port);
$lines = explode("\n", rtrim($buf, "\r\n")); $lines = explode("\n", rtrim($buf, "\r\n"));
foreach ($lines as $line) { foreach ($lines as $line) {
$line = rtrim($line, "\r\n"); $line = rtrim($line, "\r\n");
if ($line !== '') { 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 public function stop(): void
{ {
foreach ($this->tcpClients as $id => $clients) { foreach ($this->tcpClients as $id => $clients) {