Log using printf with a String stored in PROGMEM. Always.

This commit is contained in:
Fabian Schlenz 2019-06-18 18:13:37 +02:00
parent 5af7c6337d
commit 5a02050680

View File

@ -78,15 +78,33 @@
#ifdef DEBUG #ifdef DEBUG
#ifdef MQTT_ENABLE #ifdef MQTT_ENABLE
#include "my_mqtt.h" #include "my_mqtt.h"
#define LOG(x) mqtt_log(x); Serial.print(x); #define LOG(msg, ...) do { \
#define LOGln(x) mqtt_log_ln(x); Serial.println(x); char buffer[128]; \
snprintf_P(buffer, 128, PSTR(msg), ##__VA_ARGS__);\
mqtt_log(buffer);\
Serial.print(buffer);\
} while (0);
#define LOGln(msg, ...) do {\
char buffer[128]; \
snprintf_P(buffer, 128, PSTR(msg), ##__VA_ARGS__);\
mqtt_log_ln(buffer);\
Serial.println(buffer);\
} while (0);
#else #else
#define LOG(x) Serial.print(x); #define LOG(msg, ...) do { \
#define LOGln(x) Serial.println(x); char buffer[128]; \
snprintf_P(buffer, 128, PSTR(msg), ##__VA_ARGS__);\
Serial.print(buffer);\
} while (0);
#define LOGln(msg, ...) do { \
char buffer[128]; \
snprintf_P(buffer, 128, PSTR(msg), ##__VA_ARGS__);\
Serial.println(buffer);\
} while (0);
#endif #endif
#else #else
#define LOG(x) do {} while(0); #define LOG(msg, ...) do {} while(0);
#define LOGln(x) do {} while(0); #define LOGln(msg, ...) do {} while(0);
#endif #endif
#if !defined( ESP8266 ) && !defined( ESP32 ) #if !defined( ESP8266 ) && !defined( ESP32 )