diff --git a/code/components/jomjol_logfile/ClassLogFile.cpp b/code/components/jomjol_logfile/ClassLogFile.cpp index 05667514..d866eb53 100644 --- a/code/components/jomjol_logfile/ClassLogFile.cpp +++ b/code/components/jomjol_logfile/ClassLogFile.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -206,6 +207,8 @@ void ClassLogFile::WriteToFile(esp_log_level_t level, std::string info, bool _ti strftime(buffer, 30, logfile.c_str(), timeinfo); std::string logpath = logroot + "/" + buffer; + std::replace(info.begin(), info.end(), '\n', ' '); // Replace all newline characters + WriteToDedicatedFile(logpath, level, info, _time); ESP_LOG_LEVEL(level, TAG, "%s", info.c_str()); } diff --git a/code/components/jomjol_mqtt/interface_mqtt.cpp b/code/components/jomjol_mqtt/interface_mqtt.cpp index 8becc4a7..1f30d525 100644 --- a/code/components/jomjol_mqtt/interface_mqtt.cpp +++ b/code/components/jomjol_mqtt/interface_mqtt.cpp @@ -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);