truncate log MQTT contents when they are too long and remove all newline characters in logfile writes

This commit is contained in:
CaCO3
2022-10-28 23:42:04 +02:00
parent 0867dcc6da
commit fc24db7d59
2 changed files with 8 additions and 0 deletions

View File

@@ -49,6 +49,11 @@ bool MQTTPublish(std::string _key, std::string _content, int retained_flag) {
}
}
if (_content.length() > 80) { // Truncate message if too long
_content.resize(80);
_content.append("..");
}
zw = "MQTT - Published topic: " + _key + ", content: " + _content + " (msg_id=" + std::to_string(msg_id) + ")";
LogFile.WriteToFile(ESP_LOG_DEBUG, zw);