diff --git a/include/logging/log_ctrl.h b/include/logging/log_ctrl.h index 698ecf311f5..14d337a12c3 100644 --- a/include/logging/log_ctrl.h +++ b/include/logging/log_ctrl.h @@ -64,9 +64,11 @@ void log_thread_set(k_tid_t process_tid); int log_set_timestamp_func(timestamp_get_t timestamp_getter, u32_t freq); /** - * @brief Switch logger subsystem to panic mode. + * @brief Switch the logger subsystem to the panic mode. * - * @details On panic logger subsystem informs all backends about panic mode. + * Returns immediately if the logger is already in the panic mode. + * + * @details On panic the logger subsystem informs all backends about panic mode. * Backends must switch to blocking mode or halt. All pending logs * are flushed after switching to panic mode. In panic mode, all log * messages must be processed in the context of the call. diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c index 41799ef1aef..1586e192130 100644 --- a/subsys/logging/log_core.c +++ b/subsys/logging/log_core.c @@ -299,6 +299,10 @@ void log_panic(void) { struct log_backend const *backend; + if (panic_mode) { + return; + } + for (int i = 0; i < log_backend_count_get(); i++) { backend = log_backend_get(i);