Skip to content

Commit 2d6a226

Browse files
nordic-krchnashif
authored andcommitted
logging: Fix lost printk output when no newline
Log_output module was always postfixing printk strings with '\r'. If printk message did not ended with '\n' it lead to last printk message being overwritten. Fixed by adding '\r' only when string was ended by '\n'. Signed-off-by: Krzysztof Chruscinski <[email protected]>
1 parent e450589 commit 2d6a226

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

subsys/logging/log_output.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,17 +359,25 @@ static void raw_string_print(struct log_msg *msg,
359359

360360
size_t offset = 0;
361361
size_t length;
362+
bool eol = false;
362363

363364
do {
364365
length = log_output->size;
365366
/* Sting is stored in a hexdump message. */
366367
log_msg_hexdump_data_get(msg, log_output->buf, &length, offset);
367368
log_output->control_block->offset = length;
369+
370+
if (length) {
371+
eol = (log_output->buf[length - 1] == '\n');
372+
}
373+
368374
log_output_flush(log_output);
369375
offset += length;
370376
} while (length > 0);
371377

372-
print_formatted(log_output, "\r");
378+
if (eol) {
379+
print_formatted(log_output, "\r");
380+
}
373381
}
374382

375383
static int prefix_print(struct log_msg *msg,

0 commit comments

Comments
 (0)