Skip to content

Commit a6bf03a

Browse files
committed
多个ulog后端时不支持support_color后端的log指针偏移错误,导致保存到文件的日志出现乱码。
1 parent d71e2ac commit a6bf03a

File tree

1 file changed

+3
-2
lines changed
  • components/utilities/ulog

1 file changed

+3
-2
lines changed

components/utilities/ulog/ulog.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ void ulog_output_to_all_backend(rt_uint32_t level, const char *tag, rt_bool_t is
445445
{
446446
/* recalculate the log start address and log size when backend not supported color */
447447
rt_size_t color_info_len = 0, output_size = size;
448+
char *output_log = log;
448449

449450
if (color_output_info[level] != RT_NULL)
450451
color_info_len = rt_strlen(color_output_info[level]);
@@ -453,10 +454,10 @@ void ulog_output_to_all_backend(rt_uint32_t level, const char *tag, rt_bool_t is
453454
{
454455
rt_size_t color_hdr_len = rt_strlen(CSI_START) + color_info_len;
455456

456-
log += color_hdr_len;
457+
output_log += color_hdr_len;
457458
output_size -= (color_hdr_len + (sizeof(CSI_END) - 1));
458459
}
459-
backend->output(backend, level, tag, is_raw, log, output_size);
460+
backend->output(backend, level, tag, is_raw, output_log, output_size);
460461
}
461462
#endif /* !defined(ULOG_USING_COLOR) || defined(ULOG_USING_SYSLOG) */
462463
}

0 commit comments

Comments
 (0)