1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-08 06:06:40 +02:00

Merge pull request #1488 from previousnext/path-sockets

Adds support for unix sockets
This commit is contained in:
Jordi Boggiano
2020-08-22 12:15:55 +02:00
committed by GitHub
2 changed files with 9 additions and 2 deletions

View File

@@ -28,7 +28,14 @@ class UdpSocket
{ {
$this->ip = $ip; $this->ip = $ip;
$this->port = $port; $this->port = $port;
$this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); $domain = AF_INET;
$protocol = SOL_UDP;
// Check if we are using unix sockets.
if ($port === 0) {
$domain = AF_UNIX;
$protocol = IPPROTO_IP;
}
$this->socket = socket_create($domain, SOCK_DGRAM, $protocol);
} }
public function write($line, $header = "") public function write($line, $header = "")

View File

@@ -51,7 +51,7 @@ class SyslogUdpHandler extends AbstractSyslogHandler
$this->ident = $ident; $this->ident = $ident;
$this->rfc = $rfc; $this->rfc = $rfc;
$this->socket = new UdpSocket($host, $port ?: 514); $this->socket = new UdpSocket($host, $port);
} }
protected function write(array $record): void protected function write(array $record): void