Allow broadcasting to a specific log channel (#40)

* Allow broadcasting to a specific log channel

* Fix  check condition

* Update src/ConnectionManager.php

* Update config/mqtt-client.php

---------

Co-authored-by: Namoshek <Namoshek@users.noreply.github.com>
This commit is contained in:
bsdnomad
2023-05-15 21:04:29 +03:00
committed by GitHub
parent 0669643386
commit b059586d08
2 changed files with 9 additions and 0 deletions

View File

@@ -139,10 +139,15 @@ class ConnectionManager
$cleanSession = (bool) Arr::get($config, 'use_clean_session', true);
$repository = Arr::get($config, 'repository', Repository::class);
$loggingEnabled = (bool) Arr::get($config, 'enable_logging', true);
$logChannel = Arr::get($config, 'log_channel', null);
$settings = $this->buildConnectionSettings(Arr::get($config, 'connection_settings', []));
$repository = $this->application->make($repository);
$logger = $loggingEnabled ? $this->application->make('log') : null;
if($logger && $logChannel) {
$logger = $logger->channel($logChannel);
}
$client = new MqttClient($host, $port, $clientId, $protocol, $repository, $logger);
$client->connect($settings, $cleanSession);