Skip to content

Commit c96f80d

Browse files
Merge pull request #371 from bdraco/esp8266_logging_fix
Fix ESP8266 crash in logging macros due to __FUNCTION__ in flash
2 parents 4c86b44 + 6847b46 commit c96f80d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/AsyncWebServerLogging.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181

8282
/**
8383
* ESP8266 specific configurations
84+
* Note: __FUNCTION__ is stored in flash on ESP8266, so we use FPSTR() to handle it properly
8485
*/
8586
#elif defined(ESP8266)
8687
#include <ets_sys.h>
@@ -98,31 +99,31 @@
9899
#endif
99100
// error
100101
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_ERROR
101-
#define async_ws_log_e(format, ...) ets_printf(String(F("E async_ws %s() %d: " format)).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__);
102+
#define async_ws_log_e(format, ...) Serial.printf_P(PSTR("E async_ws %d: " format "\n"), __LINE__, ##__VA_ARGS__)
102103
#else
103104
#define async_ws_log_e(format, ...)
104105
#endif
105106
// warn
106107
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_WARN
107-
#define async_ws_log_w(format, ...) ets_printf(String(F("W async_ws %s() %d: " format)).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__);
108+
#define async_ws_log_w(format, ...) Serial.printf_P(PSTR("W async_ws %d: " format "\n"), __LINE__, ##__VA_ARGS__)
108109
#else
109110
#define async_ws_log_w(format, ...)
110111
#endif
111112
// info
112113
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_INFO
113-
#define async_ws_log_i(format, ...) ets_printf(String(F("I async_ws %s() %d: " format)).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__);
114+
#define async_ws_log_i(format, ...) Serial.printf_P(PSTR("I async_ws %d: " format "\n"), __LINE__, ##__VA_ARGS__)
114115
#else
115116
#define async_ws_log_i(format, ...)
116117
#endif
117118
// debug
118119
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_DEBUG
119-
#define async_ws_log_d(format, ...) ets_printf(String(F("D async_ws %s() %d: " format)).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__);
120+
#define async_ws_log_d(format, ...) Serial.printf_P(PSTR("D async_ws %d: " format "\n"), __LINE__, ##__VA_ARGS__)
120121
#else
121122
#define async_ws_log_d(format, ...)
122123
#endif
123124
// verbose
124125
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_VERBOSE
125-
#define async_ws_log_v(format, ...) ets_printf(String(F("V async_ws %s() %d: " format)).c_str(), __FUNCTION__, __LINE__, ##__VA_ARGS__);
126+
#define async_ws_log_v(format, ...) Serial.printf_P(PSTR("V async_ws %d: " format "\n"), __LINE__, ##__VA_ARGS__)
126127
#else
127128
#define async_ws_log_v(format, ...)
128129
#endif

0 commit comments

Comments
 (0)