make mqtt logging configurable

This commit is contained in:
technyon
2022-12-23 23:24:34 +01:00
parent e2057e024b
commit 99e0c1568f
4 changed files with 27 additions and 10 deletions

View File

@@ -41,10 +41,16 @@ WifiDevice::WifiDevice(const String& hostname, Preferences* _preferences)
_mqttClient = new PubSubClient(*_wifiClient);
}
String pathStr = _preferences->getString(preference_mqtt_lock_path);
pathStr.concat(mqtt_topic_log);
strcpy(_path, pathStr.c_str());
Log = new MqttLogger(*_mqttClient, _path);
if(_preferences->getBool(preference_mqtt_log_enabled))
{
_path = new char[200];
memset(_path, 0, sizeof(_path));
String pathStr = _preferences->getString(preference_mqtt_lock_path);
pathStr.concat(mqtt_topic_log);
strcpy(_path, pathStr.c_str());
Log = new MqttLogger(*_mqttClient, _path);
}
}
PubSubClient *WifiDevice::mqttClient()