Skip to content

Commit ddf160a

Browse files
kwd-doodlingkartben
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 3b192aa commit ddf160a

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
@@ -288,6 +288,14 @@ void log_core_init(void)
288288
if (IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) {
289289
z_log_runtime_filters_init();
290290
}
291+
292+
STRUCT_SECTION_FOREACH(log_backend, backend) {
293+
uint32_t id;
294+
/* As first slot in filtering mask is reserved, backend ID has offset.*/
295+
id = LOG_FILTER_FIRST_BACKEND_SLOT_IDX;
296+
id += backend - log_backend_get(0);
297+
log_backend_id_set(backend, id);
298+
}
291299
}
292300

293301
static uint32_t activate_foreach_backend(uint32_t mask)
@@ -331,12 +339,6 @@ static uint32_t z_log_init(bool blocking, bool can_sleep)
331339
int backend_index = 0;
332340

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

0 commit comments

Comments
 (0)