Skip to content

Commit 95813f0

Browse files
committed
(lib/printer) add newline on error printfs
1 parent 504f6e1 commit 95813f0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lib/printer.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,19 +357,31 @@ void printf_with_fileloc(
357357
* by prepending stack trace */
358358
__print_frame_unwind(NEW_BUFFER(__debug_frame_buf, 1024), 2);
359359
sprint_time(NEW_BUFFER(__debug_time_buf, 1024), read_clk(), SPRINT_TIME_HHMMSSCLK);
360+
STREAM* fmt_buf = NEW_BUFFER(__verbose_print_buf, 1024);
361+
362+
/* header is like "(TIMESTAMP) CPUn:log_level:[stack:stack:stack:stack]" */
360363
sprintf(
361-
NEW_BUFFER(__verbose_print_buf, 1024),
362-
"(%s) CPU%d:%s:[%s %s:%d (%s)] %s",
364+
fmt_buf,
365+
"(%s) CPU%d:%s:[%s %s:%d (%s)]",
363366
__debug_time_buf,
364367
cpu,
365368
level,
366369
__debug_frame_buf,
367370
filename,
368371
line,
369-
func,
370-
fmt
372+
func
371373
);
372374

375+
if (mode & PRINT_MODE_ERROR) {
376+
/* if this is an error print make sure the format appears on its own line. */
377+
sprintf(fmt_buf, ":\n# ", fmt);
378+
} else {
379+
sprintf(fmt_buf, " ", fmt);
380+
}
381+
382+
/* now write the actual printf() format string */
383+
sprintf(fmt_buf, "%s", fmt);
384+
373385
va_list ap;
374386
va_start(ap, fmt);
375387
vprintf(mode, __verbose_print_buf, ap);

0 commit comments

Comments
 (0)