Skip to content

Commit 892c25f

Browse files
Merge pull request #421 from ESP32Async/fix-logging
Fix: EOL was missing for custom log lines with Serial.printf
2 parents ed7901d + 75625c4 commit 892c25f

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

‎src/AsyncWebServerLogging.h‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
#elif defined(ASYNCWEBSERVER_LOG_DEBUG)
1212
// Local Debug logging
1313
#include <HardwareSerial.h>
14-
#define async_ws_log_e(format, ...) Serial.printf("E async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__);
15-
#define async_ws_log_w(format, ...) Serial.printf("W async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__);
16-
#define async_ws_log_i(format, ...) Serial.printf("I async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__);
17-
#define async_ws_log_d(format, ...) Serial.printf("D async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__);
18-
#define async_ws_log_v(format, ...) Serial.printf("V async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__);
14+
#define async_ws_log_e(format, ...) Serial.printf("E async_ws %s() %d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
15+
#define async_ws_log_w(format, ...) Serial.printf("W async_ws %s() %d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
16+
#define async_ws_log_i(format, ...) Serial.printf("I async_ws %s() %d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
17+
#define async_ws_log_d(format, ...) Serial.printf("D async_ws %s() %d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
18+
#define async_ws_log_v(format, ...) Serial.printf("V async_ws %s() %d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
1919

2020
#else
2121
// Framework-based logging
@@ -50,31 +50,31 @@
5050
#endif
5151
// error
5252
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_ERROR
53-
#define async_ws_log_e(format, ...) Serial.printf("E async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__);
53+
#define async_ws_log_e(format, ...) Serial.printf("E async_ws %s() %d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
5454
#else
5555
#define async_ws_log_e(format, ...)
5656
#endif
5757
// warn
5858
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_WARN
59-
#define async_ws_log_w(format, ...) Serial.printf("W async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__);
59+
#define async_ws_log_w(format, ...) Serial.printf("W async_ws %s() %d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
6060
#else
6161
#define async_ws_log_w(format, ...)
6262
#endif
6363
// info
6464
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_INFO
65-
#define async_ws_log_i(format, ...) Serial.printf("I async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__);
65+
#define async_ws_log_i(format, ...) Serial.printf("I async_ws %s() %d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
6666
#else
6767
#define async_ws_log_i(format, ...)
6868
#endif
6969
// debug
7070
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_DEBUG
71-
#define async_ws_log_d(format, ...) Serial.printf("D async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__);
71+
#define async_ws_log_d(format, ...) Serial.printf("D async_ws %s() %d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
7272
#else
7373
#define async_ws_log_d(format, ...)
7474
#endif
7575
// verbose
7676
#if ASYNCWEBSERVER_LOG_LEVEL >= ASYNC_WS_LOG_VERBOSE
77-
#define async_ws_log_v(format, ...) Serial.printf("V async_ws %s() %d: " format, __FUNCTION__, __LINE__, ##__VA_ARGS__);
77+
#define async_ws_log_v(format, ...) Serial.printf("V async_ws %s() %d: " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
7878
#else
7979
#define async_ws_log_v(format, ...)
8080
#endif

‎src/AsyncWebSocket.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,8 @@ void AsyncWebSocketClient::_onData(void *pbuf, size_t plen) {
580580

581581
while (plen > 0) {
582582
async_ws_log_v(
583-
"[%s][%" PRIu32 "] DATA plen: %" PRIu32 ", _pstate: %" PRIu8 ", _status: %" PRIu8, _server->url(), _clientId, plen, _pstate, static_cast<uint8_t>(_status)
583+
"[%s][%" PRIu32 "] DATA plen: %" PRIu32 ", _pstate: %" PRIu8 ", _status: %" PRIu8, _server->url(), _clientId, static_cast<uint32_t>(plen), _pstate,
584+
static_cast<uint8_t>(_status)
584585
);
585586

586587
if (_pstate == STATE_FRAME_START) {

0 commit comments

Comments
 (0)