mirror of https://github.com/arendst/Tasmota.git
Reduce generic log buffer to 128 chars
This commit is contained in:
parent
78ce7b142d
commit
708d231c9c
|
@ -2172,12 +2172,22 @@ void AddLogData(uint32_t loglevel, const char* log_data) {
|
|||
|
||||
void AddLog_P(uint32_t loglevel, PGM_P formatP, ...)
|
||||
{
|
||||
char log_data[LOGSZ];
|
||||
char log_data[132];
|
||||
|
||||
va_list arg;
|
||||
va_start(arg, formatP);
|
||||
vsnprintf_P(log_data, sizeof(log_data), formatP, arg);
|
||||
uint32_t len = vsnprintf_P(log_data, 129, formatP, arg);
|
||||
va_end(arg);
|
||||
if (len > 128) { strcat(log_data, "..."); } // Actual data is more
|
||||
|
||||
#ifdef DEBUG_TASMOTA_CORE
|
||||
// Profile max_len
|
||||
static uint32_t max_len = 0;
|
||||
if (len > max_len) {
|
||||
max_len = len;
|
||||
Serial.printf("PRF: AddLog_P %d\n", max_len);
|
||||
}
|
||||
#endif
|
||||
|
||||
AddLogData(loglevel, log_data);
|
||||
}
|
||||
|
@ -2188,9 +2198,18 @@ void AddLog_Debug(PGM_P formatP, ...)
|
|||
|
||||
va_list arg;
|
||||
va_start(arg, formatP);
|
||||
vsnprintf_P(log_data, sizeof(log_data), formatP, arg);
|
||||
uint32_t len = vsnprintf_P(log_data, sizeof(log_data), formatP, arg);
|
||||
va_end(arg);
|
||||
|
||||
#ifdef DEBUG_TASMOTA_CORE
|
||||
// Profile max_len
|
||||
static uint32_t max_len = 0;
|
||||
if (len > max_len) {
|
||||
max_len = len;
|
||||
Serial.printf("PRF: AddLog_Debug %d\n", max_len);
|
||||
}
|
||||
#endif
|
||||
|
||||
AddLogData(LOG_LEVEL_DEBUG, log_data);
|
||||
}
|
||||
|
||||
|
@ -2211,7 +2230,7 @@ void AddLogMissed(const char *sensor, uint32_t misses)
|
|||
}
|
||||
|
||||
void AddLogBufferSize(uint32_t loglevel, uint8_t *buffer, uint32_t count, uint32_t size) {
|
||||
char log_data[LOGSZ];
|
||||
char log_data[4 + (count * size * 3)];
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("DMP:"));
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
|
|
|
@ -218,11 +218,13 @@ bool MqttPublishLib(const char* topic, bool retained) {
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_TASMOTA_CORE
|
||||
void MqttDumpData(char* topic, char* data, uint32_t data_len) {
|
||||
char dump_data[data_len +1];
|
||||
memcpy(dump_data, data, sizeof(dump_data)); // Make another copy for removing optional control characters
|
||||
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_MQTT D_DATA_SIZE " %d, \"%s %s\""), data_len, topic, RemoveControlCharacter(dump_data));
|
||||
DEBUG_CORE_LOG(PSTR(D_LOG_MQTT "Size %d, \"%s %s\""), data_len, topic, RemoveControlCharacter(dump_data));
|
||||
}
|
||||
#endif
|
||||
|
||||
void MqttDataHandler(char* mqtt_topic, uint8_t* mqtt_data, unsigned int data_len) {
|
||||
#ifdef USE_DEBUG_DRIVER
|
||||
|
@ -248,9 +250,9 @@ void MqttDataHandler(char* mqtt_topic, uint8_t* mqtt_data, unsigned int data_len
|
|||
char data[data_len +1];
|
||||
memcpy(data, mqtt_data, sizeof(data));
|
||||
|
||||
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_MQTT D_DATA_SIZE " %d, \"%s %s\""), data_len, topic, data);
|
||||
// if (LOG_LEVEL_DEBUG_MORE <= TasmotaGlobal.seriallog_level) { Serial.println(data); }
|
||||
#ifdef DEBUG_TASMOTA_CORE
|
||||
MqttDumpData(topic, data, data_len); // Use a function to save stack space used by dump_data
|
||||
#endif
|
||||
|
||||
// MQTT pre-processing
|
||||
XdrvMailbox.index = strlen(topic);
|
||||
|
|
Loading…
Reference in New Issue