Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions subsys/logging/log_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,18 @@ static int ids_print(const struct log_output *output,
}

if (IS_ENABLED(CONFIG_LOG_THREAD_ID_PREFIX) && thread_on) {
if (IS_ENABLED(CONFIG_THREAD_NAME)) {
total += print_formatted(output, "[%s] ",
tid == NULL ? "irq" : k_thread_name_get(tid));
if (tid == NULL) {
total += print_formatted(output, "[irq] ");
} else if (IS_ENABLED(CONFIG_THREAD_NAME)) {
total += print_formatted(output,
"[%3d %s] ",
k_thread_priority_get(tid),
k_thread_name_get(tid));
} else {
total += print_formatted(output, "[%p] ", tid);
total += print_formatted(output,
"[%3d %p] ",
k_thread_priority_get(tid),
tid);
}
}

Expand Down
8 changes: 6 additions & 2 deletions tests/subsys/logging/log_output/src/log_output_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,14 @@ ZTEST(test_log_output, test_thread_id)
char exp_str[256];
char package[256];

k_tid_t tid = k_current_get();
const char *name = k_thread_name_get(tid);
int prio = k_thread_priority_get(tid);

if (IS_ENABLED(CONFIG_THREAD_NAME)) {
sprintf(exp_str, "<err> [%s] src: Test\r\n", k_thread_name_get(k_current_get()));
sprintf(exp_str, "<err> [%3d %s] src: Test\r\n", prio, name);
} else {
sprintf(exp_str, "<err> [%p] src: Test\r\n", k_current_get());
sprintf(exp_str, "<err> [%3d %p] src: Test\r\n", prio, tid);
}

uint32_t flags = LOG_OUTPUT_FLAG_LEVEL | LOG_OUTPUT_FLAG_THREAD;
Expand Down