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 <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2018-11-22 12:33:45 +01:00 committed by Anas Nashif
commit 2d6a226b2e

View file

@ -359,17 +359,25 @@ static void raw_string_print(struct log_msg *msg,
size_t offset = 0;
size_t length;
bool eol = false;
do {
length = log_output->size;
/* Sting is stored in a hexdump message. */
log_msg_hexdump_data_get(msg, log_output->buf, &length, offset);
log_output->control_block->offset = length;
if (length) {
eol = (log_output->buf[length - 1] == '\n');
}
log_output_flush(log_output);
offset += length;
} while (length > 0);
print_formatted(log_output, "\r");
if (eol) {
print_formatted(log_output, "\r");
}
}
static int prefix_print(struct log_msg *msg,