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)
266void z_log_printk(
const char *fmt, va_list ap);
269 z_log_printk(fmt, ap);
289char *z_log_strdup(
const char *str);
296 return z_log_strdup(str);
301#define LOG_IN_CPLUSPLUS 1
307#if !defined(CONFIG_LOG)
308#define _LOG_LEVEL_RESOLVE(...) LOG_LEVEL_NONE
310#define _LOG_LEVEL_RESOLVE(...) \
311 Z_LOG_EVAL(LOG_LEVEL, \
312 (GET_ARG_N(2, __VA_ARGS__, LOG_LEVEL)), \
313 (GET_ARG_N(2, __VA_ARGS__, CONFIG_LOG_DEFAULT_LEVEL)))
317#define _LOG_ARG1(arg1, ...) arg1
319#define _LOG_MODULE_CONST_DATA_CREATE(_name, _level) \
320 IF_ENABLED(LOG_IN_CPLUSPLUS, (extern)) \
321 const struct log_source_const_data LOG_ITEM_CONST_DATA(_name) \
322 __attribute__ ((section("." STRINGIFY(LOG_ITEM_CONST_DATA(_name))))) \
323 __attribute__((used)) = { \
324 .name = STRINGIFY(_name), \
328#define _LOG_MODULE_DYNAMIC_DATA_CREATE(_name) \
329 struct log_source_dynamic_data LOG_ITEM_DYNAMIC_DATA(_name) \
330 __attribute__ ((section("." STRINGIFY( \
331 LOG_ITEM_DYNAMIC_DATA(_name)))) \
333 __attribute__((used))
335#define _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name) \
336 IF_ENABLED(CONFIG_LOG_RUNTIME_FILTERING, \
337 (_LOG_MODULE_DYNAMIC_DATA_CREATE(_name);))
339#define _LOG_MODULE_DATA_CREATE(_name, _level) \
340 _LOG_MODULE_CONST_DATA_CREATE(_name, _level); \
341 _LOG_MODULE_DYNAMIC_DATA_COND_CREATE(_name)
375#define LOG_MODULE_REGISTER(...) \
377 _LOG_LEVEL_RESOLVE(__VA_ARGS__), \
378 (_LOG_MODULE_DATA_CREATE(GET_ARG_N(1, __VA_ARGS__), \
379 _LOG_LEVEL_RESOLVE(__VA_ARGS__))),\
382 LOG_MODULE_DECLARE(__VA_ARGS__)
410#define LOG_MODULE_DECLARE(...) \
411 extern const struct log_source_const_data \
412 LOG_ITEM_CONST_DATA(GET_ARG_N(1, __VA_ARGS__)); \
413 extern struct log_source_dynamic_data \
414 LOG_ITEM_DYNAMIC_DATA(GET_ARG_N(1, __VA_ARGS__)); \
416 static const struct log_source_const_data * \
417 __log_current_const_data __unused = \
418 _LOG_LEVEL_RESOLVE(__VA_ARGS__) ? \
419 &LOG_ITEM_CONST_DATA(GET_ARG_N(1, __VA_ARGS__)) : \
422 static struct log_source_dynamic_data * \
423 __log_current_dynamic_data __unused = \
424 (_LOG_LEVEL_RESOLVE(__VA_ARGS__) && \
425 IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING)) ? \
426 &LOG_ITEM_DYNAMIC_DATA(GET_ARG_N(1, __VA_ARGS__)) : \
429 static const uint32_t __log_level __unused = \
430 _LOG_LEVEL_RESOLVE(__VA_ARGS__)
439#define LOG_LEVEL_SET(level) static const uint32_t __log_level __unused = \
440 Z_LOG_RESOLVED_LEVEL(level, 0)
446#if defined(__CDT_PARSER__)
452#undef LOG_HEXDUMP_ERR
453#undef LOG_HEXDUMP_WRN
454#undef LOG_HEXDUMP_INF
455#undef LOG_HEXDUMP_DBG
457#define LOG_ERR(...) (void) 0
458#define LOG_WRN(...) (void) 0
459#define LOG_DBG(...) (void) 0
460#define LOG_INF(...) (void) 0
462#define LOG_HEXDUMP_ERR(...) (void) 0
463#define LOG_HEXDUMP_WRN(...) (void) 0
464#define LOG_HEXDUMP_DBG(...) (void) 0
465#define LOG_HEXDUMP_INF(...) (void) 0
static char * log_strdup(const char *str)
Definition: log.h:290
static void log_printk(const char *fmt, va_list ap)
Definition: log.h:267
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition: util_macro.h:101