1 /* Copyright (c) 2023 Nordic Semiconductor ASA
2 * SPDX-License-Identifier: Apache-2.0
3 */
4
5 #ifndef ZEPHYR_TESTS_BLUETOOTH_COMMON_TESTLIB_INCLUDE_TESTLIB_LOG_UTILS_H_
6 #define ZEPHYR_TESTS_BLUETOOTH_COMMON_TESTLIB_INCLUDE_TESTLIB_LOG_UTILS_H_
7
8 #include <zephyr/logging/log_ctrl.h>
9 #include <zephyr/sys/__assert.h>
10
bt_testlib_log_level_set(char * module,uint32_t new_level)11 static inline void bt_testlib_log_level_set(char *module, uint32_t new_level)
12 {
13 int source_id;
14 uint32_t result_level;
15
16 __ASSERT_NO_MSG(IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING));
17
18 source_id = log_source_id_get(module);
19 __ASSERT(source_id >= 0, "%d", source_id);
20
21 result_level = log_filter_set(NULL, Z_LOG_LOCAL_DOMAIN_ID, source_id, new_level);
22 __ASSERT(result_level == new_level, "%u %u", result_level, new_level);
23 }
24
bt_testlib_log_level_set_all(uint32_t new_level)25 static inline void bt_testlib_log_level_set_all(uint32_t new_level)
26 {
27 uint32_t source_count;
28
29 __ASSERT_NO_MSG(IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING));
30
31 source_count = log_src_cnt_get(Z_LOG_LOCAL_DOMAIN_ID);
32
33 for (uint32_t source_id = 0; source_id < source_count; source_id++) {
34 uint32_t result_level;
35
36 result_level = log_filter_set(NULL, Z_LOG_LOCAL_DOMAIN_ID, source_id, new_level);
37 __ASSERT(result_level == new_level, "%u %u", result_level, new_level);
38 }
39 }
40
41 #endif /* ZEPHYR_TESTS_BLUETOOTH_COMMON_TESTLIB_INCLUDE_TESTLIB_LOG_UTILS_H_ */
42