1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-25 10:36:33 +02:00

Add constructor injection for SocketHandler and its children (#1600)

* feature: add constructor injection for `SocketHandler` and its children

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>

* docs: add parameter documentation to `SocketHandler#__construct`

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
This commit is contained in:
Maximilian Bösing
2021-10-13 22:29:04 +02:00
committed by GitHub
parent d1c2829268
commit 4a11cadb27
8 changed files with 174 additions and 27 deletions

View File

@@ -43,8 +43,19 @@ class LogmaticHandler extends SocketHandler
*
* @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing
*/
public function __construct(string $token, string $hostname = '', string $appname = '', bool $useSSL = true, $level = Logger::DEBUG, bool $bubble = true)
{
public function __construct(
string $token,
string $hostname = '',
string $appname = '',
bool $useSSL = true,
$level = Logger::DEBUG,
bool $bubble = true,
bool $persistent = false,
float $timeout = 0.0,
float $writingTimeout = 10.0,
?float $connectionTimeout = null,
?int $chunkSize = null
) {
if ($useSSL && !extension_loaded('openssl')) {
throw new MissingExtensionException('The OpenSSL PHP extension is required to use SSL encrypted connection for LogmaticHandler');
}
@@ -52,7 +63,16 @@ class LogmaticHandler extends SocketHandler
$endpoint = $useSSL ? 'ssl://api.logmatic.io:10515' : 'api.logmatic.io:10514';
$endpoint .= '/v1/';
parent::__construct($endpoint, $level, $bubble);
parent::__construct(
$endpoint,
$level,
$bubble,
$persistent,
$timeout,
$writingTimeout,
$connectionTimeout,
$chunkSize
);
$this->logToken = $token;
$this->hostname = $hostname;