Skip to content

Commit 4e32721

Browse files
nordic-krchnashif
authored andcommitted
logging: Add buffer flushing on entering panic
It may happen that panic occured while logger backend was formatting output data. In that case output buffer could get corrupted as logger assumes that processing happens in one context only (panic is the only exception). Added log output buffer flushing on entering panic state. Signed-off-by: Krzysztof Chruscinski <[email protected]>
1 parent 83bc07c commit 4e32721

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

subsys/logging/log_backend_native_posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void put(const struct log_backend *const backend,
8181

8282
static void panic(struct log_backend const *const backend)
8383
{
84-
/* Nothing to be done, this backend can always process logs */
84+
log_output_flush(&log_output);
8585
}
8686

8787
static void dropped(const struct log_backend *const backend, u32_t cnt)

subsys/logging/log_backend_rtt.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ static void log_backend_rtt_init(void)
232232

233233
static void panic(struct log_backend const *const backend)
234234
{
235+
log_output_flush(&log_output);
235236
panic_mode = 1;
236237
}
237238

subsys/logging/log_backend_uart.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static void log_backend_uart_init(void)
6060

6161
static void panic(struct log_backend const *const backend)
6262
{
63+
log_output_flush(&log_output);
6364
}
6465

6566
static void dropped(const struct log_backend *const backend, u32_t cnt)

0 commit comments

Comments
 (0)