Files
STM32F4-Base/Drivers/BSP/NET/lftpd/lftpd_log.c
T

28 lines
836 B
C

#include "private/lftpd_log.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "dbg_log.h"
void lftpd_log_internal(const char* level, const char* format, ...) {
static char buffer[256]; /* static: called at depth in ftpTask, keep off-stack */
static char line[288]; /* static: 组装含前缀的整行,交给控制台单写者 */
va_list args;
va_start(args, format);
int err = vsnprintf(buffer, sizeof(buffer), format, args);
va_end(args);
if (err >= sizeof(buffer)) {
return;
}
/* 走控制台单写者(App/log/console_log.c):整行一次入缓冲,避免逐字符 fputc 交错 */
int n = snprintf(line, sizeof(line), "%s %s\r\n", level, buffer);
if (n > 0) {
if (n > (int)sizeof(line) - 1) {
n = (int)sizeof(line) - 1;
}
(void)dbg_console_write_line(line, (unsigned)n);
}
}