7#ifndef ZEPHYR_INCLUDE_LOGGING_LOG_H_
8#define ZEPHYR_INCLUDE_LOGGING_LOG_H_
40#define LOG_ERR(...) Z_LOG(LOG_LEVEL_ERR, __VA_ARGS__)
51#define LOG_WRN(...) Z_LOG(LOG_LEVEL_WRN, __VA_ARGS__)
61#define LOG_INF(...) Z_LOG(LOG_LEVEL_INF, __VA_ARGS__)
71#define LOG_DBG(...) Z_LOG(LOG_LEVEL_DBG, __VA_ARGS__)
82#define LOG_PRINTK(...) Z_LOG_PRINTK(__VA_ARGS__)
96#define LOG_INST_ERR(_log_inst, ...) \
97 Z_LOG_INSTANCE(LOG_LEVEL_ERR, _log_inst, __VA_ARGS__)
112#define LOG_INST_WRN(_log_inst, ...) \
113 Z_LOG_INSTANCE(LOG_LEVEL_WRN, _log_inst, __VA_ARGS__)
127#define LOG_INST_INF(_log_inst, ...) \
128 Z_LOG_INSTANCE(LOG_LEVEL_INF, _log_inst, __VA_ARGS__)
142#define LOG_INST_DBG(_log_inst, ...) \
143 Z_LOG_INSTANCE(LOG_LEVEL_DBG, _log_inst, __VA_ARGS__)
155#define LOG_HEXDUMP_ERR(_data, _length, _str) \
156 Z_LOG_HEXDUMP(LOG_LEVEL_ERR, _data, _length, _str)
168#define LOG_HEXDUMP_WRN(_data, _length, _str) \
169 Z_LOG_HEXDUMP(LOG_LEVEL_WRN, _data, _length, _str)
180#define LOG_HEXDUMP_INF(_data, _length, _str) \
181 Z_LOG_HEXDUMP(LOG_LEVEL_INF, _data, _length, _str)
192#define LOG_HEXDUMP_DBG(_data, _length, _str) \
193 Z_LOG_HEXDUMP(LOG_LEVEL_DBG, _data, _length, _str)
209#define LOG_INST_HEXDUMP_ERR(_log_inst, _data, _length, _str) \
210 Z_LOG_HEXDUMP_INSTANCE(LOG_LEVEL_ERR, _log_inst, _data, _length, _str)
224#define LOG_INST_HEXDUMP_WRN(_log_inst, _data, _length, _str) \
225 Z_LOG_HEXDUMP_INSTANCE(LOG_LEVEL_WRN, _log_inst, _data, _length, _str)
238#define LOG_INST_HEXDUMP_INF(_log_inst, _data, _length, _str) \
239 Z_LOG_HEXDUMP_INSTANCE(LOG_LEVEL_INF, _log_inst, _data, _length, _str)
252#define LOG_INST_HEXDUMP_DBG(_log_inst, _data, _length, _str) \
253 Z_LOG_HEXDUMP_INSTANCE(LOG_LEVEL_DBG, _log_inst, _data, _length, _str)
268void z_log_vprintk(
const char *fmt, va_list ap);
287char *z_log_strdup(
const char *str);
294 return z_log_strdup(str);
299#define LOG_IN_CPLUSPLUS 1
305#if !defined(CONFIG_LOG)
306#define _LOG_LEVEL_RESOLVE(...) LOG_LEVEL_NONE
308#define _LOG_LEVEL_RESOLVE(...) \
309 Z_LOG_EVAL(LOG_LEVEL, \
310 (GET_ARG_N(2, __VA_ARGS__, LOG_LEVEL)), \
311 (GET_ARG_N(2, __VA_ARGS__, CONFIG_LOG_DEFAULT_LEVEL)))
315#define _LOG_ARG1(arg1, ...) arg1
317#define _LOG_MODULE_CONST_DATA_CREATE(_name, _level) \
318 IF_ENABLED(LOG_IN_CPLUSPLUS, (extern)) \
319 const struct log_source_const_data Z_LOG_ITEM_CONST_DATA(_name) \
320 __attribute__ ((section("." STRINGIFY(Z_LOG_ITEM_CONST_DATA(_name))))) \
321 __attribute__((used)) = { \
322 .name = STRINGIFY(_name), \
326#define _LOG_MODULE_DYNAMIC_DATA_CREATE(_name) \
327 struct log_source_dynamic_data LOG_ITEM_DYNAMIC_DATA(_name) \
328 __attribute__ ((section("." STRINGIFY( \
329 LOG_ITEM_DYNAMIC_DATA(_name)))) \
331 __attribute__((used))
333#define _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name) \
334 IF_ENABLED(CONFIG_LOG_RUNTIME_FILTERING, \
335 (_LOG_MODULE_DYNAMIC_DATA_CREATE(_name);))
337#define _LOG_MODULE_DATA_CREATE(_name, _level) \
338 _LOG_MODULE_CONST_DATA_CREATE(_name, _level); \
339 _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name)
373#define LOG_MODULE_REGISTER(...) \
375 _LOG_LEVEL_RESOLVE(__VA_ARGS__), \
376 (_LOG_MODULE_DATA_CREATE(GET_ARG_N(1, __VA_ARGS__), \
377 _LOG_LEVEL_RESOLVE(__VA_ARGS__))),\
380 LOG_MODULE_DECLARE(__VA_ARGS__)
408#define LOG_MODULE_DECLARE(...) \
409 extern const struct log_source_const_data \
410 Z_LOG_ITEM_CONST_DATA(GET_ARG_N(1, __VA_ARGS__)); \
411 extern struct log_source_dynamic_data \
412 LOG_ITEM_DYNAMIC_DATA(GET_ARG_N(1, __VA_ARGS__)); \
414 static const struct log_source_const_data * \
415 __log_current_const_data __unused = \
416 _LOG_LEVEL_RESOLVE(__VA_ARGS__) ? \
417 &Z_LOG_ITEM_CONST_DATA(GET_ARG_N(1, __VA_ARGS__)) : \
420 static struct log_source_dynamic_data * \
421 __log_current_dynamic_data __unused = \
422 (_LOG_LEVEL_RESOLVE(__VA_ARGS__) && \
423 IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) ? \
424 &LOG_ITEM_DYNAMIC_DATA(GET_ARG_N(1, __VA_ARGS__)) : \
427 static const uint32_t __log_level __unused = \
428 _LOG_LEVEL_RESOLVE(__VA_ARGS__)
437#define LOG_LEVEL_SET(level) static const uint32_t __log_level __unused = \
438 Z_LOG_RESOLVED_LEVEL(level, 0)
444#if defined(__CDT_PARSER__)
450#undef LOG_HEXDUMP_ERR
451#undef LOG_HEXDUMP_WRN
452#undef LOG_HEXDUMP_INF
453#undef LOG_HEXDUMP_DBG
455#define LOG_ERR(...) (void) 0
456#define LOG_WRN(...) (void) 0
457#define LOG_DBG(...) (void) 0
458#define LOG_INF(...) (void) 0
460#define LOG_HEXDUMP_ERR(...) (void) 0
461#define LOG_HEXDUMP_WRN(...) (void) 0
462#define LOG_HEXDUMP_DBG(...) (void) 0
463#define LOG_HEXDUMP_INF(...) (void) 0
static char * log_strdup(const char *str)
Definition: log.h:288
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition: util_macro.h:101