Skip to content

Commit

Permalink
(lib/printer) add newline on error printfs
Browse files Browse the repository at this point in the history
  • Loading branch information
bensimner committed May 28, 2024
1 parent 504f6e1 commit 95813f0
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,19 +357,31 @@ void printf_with_fileloc(
* by prepending stack trace */
__print_frame_unwind(NEW_BUFFER(__debug_frame_buf, 1024), 2);
sprint_time(NEW_BUFFER(__debug_time_buf, 1024), read_clk(), SPRINT_TIME_HHMMSSCLK);
STREAM* fmt_buf = NEW_BUFFER(__verbose_print_buf, 1024);

/* header is like "(TIMESTAMP) CPUn:log_level:[stack:stack:stack:stack]" */
sprintf(
NEW_BUFFER(__verbose_print_buf, 1024),
"(%s) CPU%d:%s:[%s %s:%d (%s)] %s",
fmt_buf,
"(%s) CPU%d:%s:[%s %s:%d (%s)]",
__debug_time_buf,
cpu,
level,
__debug_frame_buf,
filename,
line,
func,
fmt
func
);

if (mode & PRINT_MODE_ERROR) {
/* if this is an error print make sure the format appears on its own line. */
sprintf(fmt_buf, ":\n# ", fmt);
} else {
sprintf(fmt_buf, " ", fmt);
}

/* now write the actual printf() format string */
sprintf(fmt_buf, "%s", fmt);

va_list ap;
va_start(ap, fmt);
vprintf(mode, __verbose_print_buf, ap);
Expand Down

0 comments on commit 95813f0

Please sign in to comment.