|
Zephyr API 3.6.99
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
7#ifndef ZEPHYR_INCLUDE_LOGGING_LOG_H_
8#define ZEPHYR_INCLUDE_LOGGING_LOG_H_
44#define LOG_ERR(...) Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
55#define LOG_WRN(...) Z_LOG(LOG_LEVEL_WRN, __VA_ARGS__)
65#define LOG_INF(...) Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
75#define LOG_DBG(...) Z_LOG(LOG_LEVEL_DBG, __VA_ARGS__)
86#define LOG_WRN_ONCE(...) \
88 static uint8_t __warned; \
89 if (unlikely(__warned == 0)) { \
90 Z_LOG(LOG_LEVEL_WRN, __VA_ARGS__); \
104#define LOG_PRINTK(...) Z_LOG_PRINTK(0, __VA_ARGS__)
114#define LOG_RAW(...) Z_LOG_PRINTK(1, __VA_ARGS__)
128#define LOG_INST_ERR(_log_inst, ...) \
129 Z_LOG_INSTANCE(LOG_LEVEL_ERR, _log_inst, __VA_ARGS__)
144#define LOG_INST_WRN(_log_inst, ...) \
145 Z_LOG_INSTANCE(LOG_LEVEL_WRN, _log_inst, __VA_ARGS__)
159#define LOG_INST_INF(_log_inst, ...) \
160 Z_LOG_INSTANCE(LOG_LEVEL_INF, _log_inst, __VA_ARGS__)
174#define LOG_INST_DBG(_log_inst, ...) \
175 Z_LOG_INSTANCE(LOG_LEVEL_DBG, _log_inst, __VA_ARGS__)
187#define LOG_HEXDUMP_ERR(_data, _length, _str) \
188 Z_LOG_HEXDUMP(LOG_LEVEL_ERR, _data, _length, (_str))
200#define LOG_HEXDUMP_WRN(_data, _length, _str) \
201 Z_LOG_HEXDUMP(LOG_LEVEL_WRN, _data, _length, (_str))
212#define LOG_HEXDUMP_INF(_data, _length, _str) \
213 Z_LOG_HEXDUMP(LOG_LEVEL_INF, _data, _length, (_str))
224#define LOG_HEXDUMP_DBG(_data, _length, _str) \
225 Z_LOG_HEXDUMP(LOG_LEVEL_DBG, _data, _length, (_str))
241#define LOG_INST_HEXDUMP_ERR(_log_inst, _data, _length, _str) \
242 Z_LOG_HEXDUMP_INSTANCE(LOG_LEVEL_ERR, _log_inst, _data, _length, _str)
256#define LOG_INST_HEXDUMP_WRN(_log_inst, _data, _length, _str) \
257 Z_LOG_HEXDUMP_INSTANCE(LOG_LEVEL_WRN, _log_inst, _data, _length, _str)
270#define LOG_INST_HEXDUMP_INF(_log_inst, _data, _length, _str) \
271 Z_LOG_HEXDUMP_INSTANCE(LOG_LEVEL_INF, _log_inst, _data, _length, _str)
284#define LOG_INST_HEXDUMP_DBG(_log_inst, _data, _length, _str) \
285 Z_LOG_HEXDUMP_INSTANCE(LOG_LEVEL_DBG, _log_inst, _data, _length, _str)
299void z_log_vprintk(
const char *fmt, va_list ap);
303#define LOG_IN_CPLUSPLUS 1
309#if !defined(CONFIG_LOG)
310#define _LOG_LEVEL_RESOLVE(...) LOG_LEVEL_NONE
312#define _LOG_LEVEL_RESOLVE(...) \
313 Z_LOG_EVAL(COND_CODE_0(LOG_LEVEL, (1), (LOG_LEVEL)), \
314 (GET_ARG_N(2, __VA_ARGS__, LOG_LEVEL)), \
315 (GET_ARG_N(2, __VA_ARGS__, CONFIG_LOG_DEFAULT_LEVEL)))
319#define _LOG_ARG1(arg1, ...) arg1
321#define _LOG_MODULE_CONST_DATA_CREATE(_name, _level) \
322 IF_ENABLED(CONFIG_LOG_FMT_SECTION, ( \
323 static const char UTIL_CAT(_name, _str)[] \
324 __in_section(_log_strings, static, _CONCAT(_name, _)) __used __noasan = \
325 STRINGIFY(_name);)) \
326 IF_ENABLED(LOG_IN_CPLUSPLUS, (extern)) \
327 const STRUCT_SECTION_ITERABLE_ALTERNATE(log_const, \
328 log_source_const_data, \
329 Z_LOG_ITEM_CONST_DATA(_name)) = \
331 .name = COND_CODE_1(CONFIG_LOG_FMT_SECTION, \
332 (UTIL_CAT(_name, _str)), (STRINGIFY(_name))), \
336#define _LOG_MODULE_DYNAMIC_DATA_CREATE(_name) \
337 STRUCT_SECTION_ITERABLE_ALTERNATE(log_dynamic, log_source_dynamic_data, \
338 LOG_ITEM_DYNAMIC_DATA(_name))
340#define _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name) \
341 IF_ENABLED(CONFIG_LOG_RUNTIME_FILTERING, \
342 (_LOG_MODULE_DYNAMIC_DATA_CREATE(_name);))
344#define _LOG_MODULE_DATA_CREATE(_name, _level) \
345 _LOG_MODULE_CONST_DATA_CREATE(_name, _level); \
346 _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name)
351#define Z_DO_LOG_MODULE_REGISTER(...) \
352 COND_CODE_1(CONFIG_LOG, \
353 (Z_LOG_EVAL(CONFIG_LOG_OVERRIDE_LEVEL, \
355 (Z_LOG_EVAL(_LOG_LEVEL_RESOLVE(__VA_ARGS__), (1), (0))) \
389#define LOG_MODULE_REGISTER(...) \
391 Z_DO_LOG_MODULE_REGISTER(__VA_ARGS__), \
392 (_LOG_MODULE_DATA_CREATE(GET_ARG_N(1, __VA_ARGS__), \
393 _LOG_LEVEL_RESOLVE(__VA_ARGS__))),\
396 LOG_MODULE_DECLARE(__VA_ARGS__)
424#define LOG_MODULE_DECLARE(...) \
425 extern const struct log_source_const_data \
426 Z_LOG_ITEM_CONST_DATA(GET_ARG_N(1, __VA_ARGS__)); \
427 extern struct log_source_dynamic_data \
428 LOG_ITEM_DYNAMIC_DATA(GET_ARG_N(1, __VA_ARGS__)); \
430 static const struct log_source_const_data * \
431 __log_current_const_data __unused = \
432 Z_DO_LOG_MODULE_REGISTER(__VA_ARGS__) ? \
433 &Z_LOG_ITEM_CONST_DATA(GET_ARG_N(1, __VA_ARGS__)) : \
436 static struct log_source_dynamic_data * \
437 __log_current_dynamic_data __unused = \
438 (Z_DO_LOG_MODULE_REGISTER(__VA_ARGS__) && \
439 IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) ? \
440 &LOG_ITEM_DYNAMIC_DATA(GET_ARG_N(1, __VA_ARGS__)) : \
443 static const uint32_t __log_level __unused = \
444 _LOG_LEVEL_RESOLVE(__VA_ARGS__)
453#define LOG_LEVEL_SET(level) static const uint32_t __log_level __unused = \
454 Z_LOG_RESOLVED_LEVEL(level, 0)
456#ifdef CONFIG_LOG_CUSTOM_HEADER
458#include <zephyr_custom_log.h>
465#if defined(__CDT_PARSER__) || defined(__JETBRAINS_IDE__)
471#undef LOG_HEXDUMP_ERR
472#undef LOG_HEXDUMP_WRN
473#undef LOG_HEXDUMP_INF
474#undef LOG_HEXDUMP_DBG
476#define LOG_ERR(...) (void) 0
477#define LOG_WRN(...) (void) 0
478#define LOG_DBG(...) (void) 0
479#define LOG_INF(...) (void) 0
481#define LOG_HEXDUMP_ERR(...) (void) 0
482#define LOG_HEXDUMP_WRN(...) (void) 0
483#define LOG_HEXDUMP_DBG(...) (void) 0
484#define LOG_HEXDUMP_INF(...) (void) 0