Skip to content

Commit e1f609f

Browse files
wdfk-progRbb666
authored andcommitted
feat(ulog): Add a one-time warning when the log line buffer is insufficient
1 parent de784f7 commit e1f609f

File tree

1 file changed

+13
-0
lines changed
  • components/utilities/ulog

1 file changed

+13
-0
lines changed

components/utilities/ulog/ulog.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,17 @@ rt_weak rt_size_t ulog_tail_formater(char *log_buf, rt_size_t log_len, rt_bool_t
421421
return log_len;
422422
}
423423

424+
static void ulog_no_enough_buffer_printf(void)
425+
{
426+
static rt_bool_t already_output = RT_FALSE;
427+
if (already_output == RT_FALSE)
428+
{
429+
rt_kprintf("Warning: There is not enough buffer to output the log,"
430+
" please increase the ULOG_LINE_BUF_SIZE option.\n");
431+
already_output = RT_TRUE;
432+
}
433+
}
434+
424435
rt_weak rt_size_t ulog_formater(char *log_buf, rt_uint32_t level, const char *tag, rt_bool_t newline,
425436
const char *format, va_list args)
426437
{
@@ -444,6 +455,7 @@ rt_weak rt_size_t ulog_formater(char *log_buf, rt_uint32_t level, const char *ta
444455
{
445456
/* using max length */
446457
log_len = ULOG_LINE_BUF_SIZE;
458+
ulog_no_enough_buffer_printf();
447459
}
448460
/* log tail */
449461
return ulog_tail_formater(log_buf, log_len, newline, level);
@@ -472,6 +484,7 @@ rt_weak rt_size_t ulog_hex_formater(char *log_buf, const char *tag, const rt_uin
472484
else
473485
{
474486
log_len = ULOG_LINE_BUF_SIZE;
487+
ulog_no_enough_buffer_printf();
475488
}
476489
/* dump hex */
477490
for (j = 0; j < width; j++)

0 commit comments

Comments
 (0)