Skip to content

Commit

Permalink
Add chunk_size option for udp transport
Browse files Browse the repository at this point in the history
Close #45
  • Loading branch information
hedii committed Jun 1, 2023
1 parent 4c973e2 commit c03f2b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 4 additions & 1 deletion src/GelfLoggerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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;
Expand All @@ -85,6 +87,7 @@ protected function getTransport(
string $transport,
string $host,
int $port,
int $chunkSize,
?string $path = null,
?SslOptions $sslOptions = null
): AbstractTransport {
Expand All @@ -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),
};
}

Expand Down

0 comments on commit c03f2b3

Please sign in to comment.