Skip to content

Commit 0fb81de

Browse files
kwd-doodlingdkalowsk
authored andcommitted
logging: Assign IDs to log backends early during log_core_init
This commit moves the assignment of backend IDs from the 'z_log_init' function to the earlier 'log_core_init' function. This ensures that backend IDs are assigned before they are used in the 'log_backend_enable' function, preventing incorrect settings of log dynamic filters. Signed-off-by: Dong Wang <[email protected]> (cherry picked from commit 3fac831)
1 parent 1cdd63e commit 0fb81de

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

subsys/logging/log_core.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,14 @@ void log_core_init(void)
286286
if (IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) {
287287
z_log_runtime_filters_init();
288288
}
289+
290+
STRUCT_SECTION_FOREACH(log_backend, backend) {
291+
uint32_t id;
292+
/* As first slot in filtering mask is reserved, backend ID has offset.*/
293+
id = LOG_FILTER_FIRST_BACKEND_SLOT_IDX;
294+
id += backend - log_backend_get(0);
295+
log_backend_id_set(backend, id);
296+
}
289297
}
290298

291299
static uint32_t activate_foreach_backend(uint32_t mask)
@@ -329,12 +337,6 @@ static uint32_t z_log_init(bool blocking, bool can_sleep)
329337
int backend_index = 0;
330338

331339
STRUCT_SECTION_FOREACH(log_backend, backend) {
332-
uint32_t id;
333-
/* As first slot in filtering mask is reserved, backend ID has offset.*/
334-
id = LOG_FILTER_FIRST_BACKEND_SLOT_IDX;
335-
id += backend - log_backend_get(0);
336-
log_backend_id_set(backend, id);
337-
338340
/* Activate autostart backends */
339341
if (backend->autostart) {
340342
log_backend_init(backend);

0 commit comments

Comments
 (0)