diff options
| author | 梁林 <[email protected]> | 2021-08-19 09:13:16 +0800 |
|---|---|---|
| committer | 梁林 <[email protected]> | 2021-08-19 09:13:16 +0800 |
| commit | a6bf03a0c8cc98a95d1ee9097d0e5a77bff28ea3 (patch) | |
| tree | a6bb3124d5f4387beaa27961a5eec7ffb3de1f15 | |
| parent | d71e2ac5829925e8a9fc7203fda8830eeda44ecc (diff) | |
多个ulog后端时不支持support_color后端的log指针偏移错误,导致保存到文件的日志出现乱码。
| -rw-r--r-- | components/utilities/ulog/ulog.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index c36fc6ff26..dfba4b14e0 100644 --- a/components/utilities/ulog/ulog.c +++ b/components/utilities/ulog/ulog.c @@ -445,6 +445,7 @@ void ulog_output_to_all_backend(rt_uint32_t level, const char *tag, rt_bool_t is { /* recalculate the log start address and log size when backend not supported color */ rt_size_t color_info_len = 0, output_size = size; + char *output_log = log; if (color_output_info[level] != RT_NULL) 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 { rt_size_t color_hdr_len = rt_strlen(CSI_START) + color_info_len; - log += color_hdr_len; + output_log += color_hdr_len; output_size -= (color_hdr_len + (sizeof(CSI_END) - 1)); } - backend->output(backend, level, tag, is_raw, log, output_size); + backend->output(backend, level, tag, is_raw, output_log, output_size); } #endif /* !defined(ULOG_USING_COLOR) || defined(ULOG_USING_SYSLOG) */ } |
