Skip to content

How log2_generic get the source_id value ? #50664

Answered by nordic-krch
shahawi-sumup asked this question in Q&A
Discussion options

You must be logged in to vote

@shahawi-sumup you are right, log2_generic is missing source_id. I will try to fix it. Meanwhile you can use directly what is called underneath however it is a bit tricky. Source is a void * which points to different thing depending on CONFIG_LOG_RUNTIME_FILTERING so something like this can be used:

void *source = IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING) ? (void *)__log_current_dynamic_data : (void *)__log_current_const_data;
z_log_msg_runtime_vcreate(CONFIG_LOG_DOMAIN_ID, source, level, NULL, 0, 0, fmt,ap);`

__log_current_dynamic_data and __log_current_const_data are declared by LOG_MODULE_REGISTER()

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by shahawi-sumup
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants