mirror of
https://github.com/espressif/arduino-esp32
synced 2024-09-21 18:38:17 +00:00
log_printf: Restructured log_printf for wrapping (#7567)
This commit is contained in:
parent
3af0b44f38
commit
165d62472a
@ -496,21 +496,18 @@ int uartGetDebug()
|
||||
return s_uart_debug_nr;
|
||||
}
|
||||
|
||||
int log_printf(const char *format, ...)
|
||||
int log_printfv(const char *format, va_list arg)
|
||||
{
|
||||
static char loc_buf[64];
|
||||
char * temp = loc_buf;
|
||||
int len;
|
||||
va_list arg;
|
||||
va_list copy;
|
||||
va_start(arg, format);
|
||||
va_copy(copy, arg);
|
||||
len = vsnprintf(NULL, 0, format, copy);
|
||||
va_end(copy);
|
||||
if(len >= sizeof(loc_buf)){
|
||||
temp = (char*)malloc(len+1);
|
||||
if(temp == NULL) {
|
||||
va_end(arg);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -528,13 +525,22 @@ int log_printf(const char *format, ...)
|
||||
xSemaphoreGive(_uart_bus_array[s_uart_debug_nr].lock);
|
||||
}
|
||||
#endif
|
||||
va_end(arg);
|
||||
if(len >= sizeof(loc_buf)){
|
||||
free(temp);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
int log_printf(const char *format, ...)
|
||||
{
|
||||
int len;
|
||||
va_list arg;
|
||||
va_start(arg, format);
|
||||
len = log_printfv(format, arg);
|
||||
va_end(arg);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
static void log_print_buf_line(const uint8_t *b, size_t len, size_t total_len){
|
||||
for(size_t i = 0; i<len; i++){
|
||||
|
Loading…
Reference in New Issue
Block a user