Skip to content

Commit 33713f6

Browse files
committed
Put logging in stream namespace
1 parent 6b538b6 commit 33713f6

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/NimBLEStream.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ void NimBLEStreamClient::notifyCallback(NimBLERemoteCharacteristic* pChar, uint8
486486
}
487487

488488
// UART logging support
489-
int uart_log_printfv(const char* format, va_list arg) {
489+
int NimBLEStream::uart_log_printfv(const char* format, va_list arg) {
490490
static char loc_buf[64];
491491
char* temp = loc_buf;
492492
uint32_t len;
@@ -513,11 +513,11 @@ int uart_log_printfv(const char* format, va_list arg) {
513513
return len;
514514
}
515515

516-
int uart_log_printf(const char* format, ...) {
516+
int NimBLEStream::uart_log_printf(const char* format, ...) {
517517
int len;
518518
va_list arg;
519519
va_start(arg, format);
520-
len = uart_log_printfv(format, arg);
520+
len = NimBLEStream::uart_log_printfv(format, arg);
521521
va_end(arg);
522522
return len;
523523
}

src/NimBLEStream.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ class NimBLEStream : public Stream {
6868
void setTxTaskStackSize(uint32_t size) { m_txTaskStackSize = size; }
6969
void setTxTaskPriority(uint32_t priority) { m_txTaskPriority = priority; }
7070

71+
// These logging macros exist to provide log output over UART so that the stream class can
72+
// be used to redirect logs without causing recursion issues.
73+
static int uart_log_printfv(const char* format, va_list arg);
74+
static int uart_log_printf(const char* format, ...);
75+
7176
// Print/Stream TX methods
7277
virtual size_t write(const uint8_t* data, size_t len) override;
7378
virtual size_t write(uint8_t data) override { return write(&data, 1); }
@@ -201,31 +206,26 @@ class NimBLEStreamClient : public NimBLEStream {
201206

202207
# endif // CONFIG_BT_NIMBLE_ENABLED && (MYNEWT_VAL(BLE_ROLE_PERIPHERAL) || MYNEWT_VAL(BLE_ROLE_CENTRAL))
203208

204-
// These logging macros exist to provide log output over UART so that it stream classes can
205-
// be used to redirect logs without causing recursion issues.
206-
static int uart_log_printfv(const char* format, va_list arg);
207-
static int uart_log_printf(const char* format, ...);
208-
209209
# if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 4
210-
# define NIMBLE_UART_LOGD(tag, format, ...) uart_log_printf("D %s: " format "\n", tag, ##__VA_ARGS__)
210+
# define NIMBLE_UART_LOGD(tag, format, ...) NimBLEStream::uart_log_printf("D %s: " format "\n", tag, ##__VA_ARGS__)
211211
# else
212212
# define NIMBLE_UART_LOGD(tag, format, ...) (void)tag
213213
# endif
214214

215215
# if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 3
216-
# define NIMBLE_UART_LOGI(tag, format, ...) uart_log_printf("I %s: " format "\n", tag, ##__VA_ARGS__)
216+
# define NIMBLE_UART_LOGI(tag, format, ...) NimBLEStream::uart_log_printf("I %s: " format "\n", tag, ##__VA_ARGS__)
217217
# else
218218
# define NIMBLE_UART_LOGI(tag, format, ...) (void)tag
219219
# endif
220220

221221
# if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 2
222-
# define NIMBLE_UART_LOGW(tag, format, ...) uart_log_printf("W %s: " format "\n", tag, ##__VA_ARGS__)
222+
# define NIMBLE_UART_LOGW(tag, format, ...) NimBLEStream::uart_log_printf("W %s: " format "\n", tag, ##__VA_ARGS__)
223223
# else
224224
# define NIMBLE_UART_LOGW(tag, format, ...) (void)tag
225225
# endif
226226

227227
# if MYNEWT_VAL(NIMBLE_CPP_LOG_LEVEL) >= 1
228-
# define NIMBLE_UART_LOGE(tag, format, ...) uart_log_printf("E %s: " format "\n", tag, ##__VA_ARGS__)
228+
# define NIMBLE_UART_LOGE(tag, format, ...) NimBLEStream::uart_log_printf("E %s: " format "\n", tag, ##__VA_ARGS__)
229229
# else
230230
# define NIMBLE_UART_LOGE(tag, format, ...) (void)tag
231231
# endif

0 commit comments

Comments
 (0)