Skip to content

Commit 9a2b240

Browse files
committed
Show ellipsis sign when log line is truncated
1 parent 9b81dbf commit 9a2b240

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/rt/rust_sched_loop.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ rust_sched_loop::log(rust_task* task, uint32_t level, char const *fmt, ...) {
5454
char buf[BUF_BYTES];
5555
va_list args;
5656
va_start(args, fmt);
57-
vsnprintf(buf, sizeof(buf), fmt, args);
57+
int formattedbytes = vsnprintf(buf, sizeof(buf), fmt, args);
58+
if( formattedbytes and (unsigned)formattedbytes > BUF_BYTES ){
59+
const char truncatedstr[] = "[...]";
60+
memcpy( &buf[BUF_BYTES-sizeof(truncatedstr)],
61+
truncatedstr,
62+
sizeof(truncatedstr));
63+
}
5864
_log.trace_ln(task, level, buf);
5965
va_end(args);
6066
}

0 commit comments

Comments
 (0)