Skip to content

Commit 4539172

Browse files
authored
Merge pull request #2687 from armink/fix_ulog
[components][ulog] Fix the log length error when using multiple non-c…
2 parents 361754e + 415d122 commit 4539172

File tree

1 file changed

+4
-4
lines changed
  • components/utilities/ulog

1 file changed

+4
-4
lines changed

components/utilities/ulog/ulog.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2018, RT-Thread Development Team
2+
* Copyright (c) 2006-2019, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -403,15 +403,15 @@ void ulog_output_to_all_backend(rt_uint32_t level, const char *tag, rt_bool_t is
403403
else
404404
{
405405
/* recalculate the log start address and log size when backend not supported color */
406-
rt_size_t color_info_len = rt_strlen(color_output_info[level]);
406+
rt_size_t color_info_len = rt_strlen(color_output_info[level]), output_size = size;
407407
if (color_info_len)
408408
{
409409
rt_size_t color_hdr_len = rt_strlen(CSI_START) + color_info_len;
410410

411411
log += color_hdr_len;
412-
size -= (color_hdr_len + (sizeof(CSI_END) - 1));
412+
output_size -= (color_hdr_len + (sizeof(CSI_END) - 1));
413413
}
414-
backend->output(backend, level, tag, is_raw, log, size);
414+
backend->output(backend, level, tag, is_raw, log, output_size);
415415
}
416416
#endif /* !defined(ULOG_USING_COLOR) || defined(ULOG_USING_SYSLOG) */
417417
}

0 commit comments

Comments
 (0)