From c03f2b37dfee68924f83dbc969bb52a6d5bbe4e9 Mon Sep 17 00:00:00 2001 From: hedii Date: Thu, 1 Jun 2023 17:18:22 +0200 Subject: [PATCH] Add chunk_size option for udp transport Close #45 --- README.md | 4 ++++ src/GelfLoggerFactory.php | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index adf4a8c..4ac48d8 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,10 @@ return [ // This optional option determines the port on which the gelf // receiver host is listening. Default is 12201 'port' => 12201, + + // This optional option determines the chunk size used when + // transferring message via UDP transport. Default is 1420. + 'chunk_size' => 1420, // This optional option determines the path used for the HTTP // transport. When forgotten or set to null, default path '/gelf' diff --git a/src/GelfLoggerFactory.php b/src/GelfLoggerFactory.php index a414e6b..04c9a79 100644 --- a/src/GelfLoggerFactory.php +++ b/src/GelfLoggerFactory.php @@ -31,6 +31,7 @@ public function __invoke(array $config): Logger $config['transport'], $config['host'], $config['port'], + $config['chunk_size'], $config['path'], $this->enableSsl($config) ? $this->sslOptions($config['ssl_options']) : null ); @@ -62,6 +63,7 @@ protected function parseConfig(array $config): array $config['transport'] ??= 'udp'; $config['host'] ??= '127.0.0.1'; $config['port'] ??= 12201; + $config['chunk_size'] ??= UdpTransport::CHUNK_SIZE_WAN; $config['path'] ??= null; $config['system_name'] ??= null; $config['extra_prefix'] ??= null; @@ -85,6 +87,7 @@ protected function getTransport( string $transport, string $host, int $port, + int $chunkSize, ?string $path = null, ?SslOptions $sslOptions = null ): AbstractTransport { @@ -93,7 +96,7 @@ protected function getTransport( 'http' => $path ? new HttpTransport($host, $port, $path, $sslOptions) : new HttpTransport($host, $port, sslOptions: $sslOptions), - default => new UdpTransport($host, $port), + default => new UdpTransport($host, $port, $chunkSize), }; }