Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
b059586d08 | |||
0669643386 |
@ -22,7 +22,7 @@
|
||||
"php": "^7.4|^8.0",
|
||||
"illuminate/config": "^7.0|^8.0|^9.0|^10.0",
|
||||
"illuminate/support": "^7.0|^8.0|^9.0|^10.0",
|
||||
"php-mqtt/client": "^1.0"
|
||||
"php-mqtt/client": "^1.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
|
@ -55,6 +55,10 @@ return [
|
||||
// with the log level as configured.
|
||||
'enable_logging' => env('MQTT_ENABLE_LOGGING', true),
|
||||
|
||||
// Which logging channel to use for logs produced by the MQTT client.
|
||||
// If left empty, the default log channel or stack is being used.
|
||||
'log_channel' => env('MQTT_LOG_CHANNEL', null),
|
||||
|
||||
// Defines which repository implementation shall be used. Currently,
|
||||
// only a MemoryRepository is supported.
|
||||
'repository' => MemoryRepository::class,
|
||||
|
@ -139,11 +139,16 @@ 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);
|
||||
|
||||
|
Reference in New Issue
Block a user