Skip to content

Commit 7b981e7

Browse files
nordic-krchandrewboie
authored andcommitted
logging: Fix lack of logging after startup
Commit ad28c2d introduced semaphore on which logger thread pends. It is possible that log messages are created before any backend is attached. In that case, logger thread pends on semaphore with pending log messages and is not waken up unless new log messages comes. Fixed by setting semaphore when first backend is attached. This wakes up logger thread and log messages can be processed. Signed-off-by: Krzysztof Chruscinski <[email protected]>
1 parent 3d4aef8 commit 7b981e7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

subsys/logging/log_core.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,14 @@ void log_backend_enable(struct log_backend const *const backend,
828828
log_backend_id_set(backend, id);
829829
backend_filter_set(backend, level);
830830
log_backend_activate(backend, ctx);
831+
832+
/* Wakeup logger thread after attaching first backend. It might be
833+
* blocked with log messages pending.
834+
*/
835+
if (!backend_attached) {
836+
k_sem_give(&log_process_thread_sem);
837+
}
838+
831839
backend_attached = true;
832840
}
833841

0 commit comments

Comments
 (0)