20#ifndef ESP_COMMON_LOG_H
21#define ESP_COMMON_LOG_H
36extern int ets_printf(
const char *fmt, ...);
38#if MODULE_ESP_LOG_COLORED
40#define LOG_RESET_COLOR "\033[0m"
41#define LOG_COLOR_E "\033[1;31m"
42#define LOG_COLOR_W "\033[1;33m"
43#define LOG_COLOR_I "\033[1m"
44#define LOG_COLOR_D "\033[0;32m"
49#define LOG_RESET_COLOR
58#if MODULE_ESP_LOG_TAGGED
60#define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%" PRIu32 ") [%s] " format LOG_RESET_COLOR
62#define LOG_TAG(level, letter, tag, format, ...) \
64 if ((unsigned)level <= (unsigned)LOG_LEVEL) { \
65 printf(LOG_FORMAT(letter, format), system_get_time_ms(), tag, ##__VA_ARGS__); \
70#define LOG_TAG_EARLY(level, letter, tag, format, ...) \
72 if (LOG_LEVEL >= level) { \
73 ets_printf(LOG_FORMAT(letter, format), system_get_time_ms(), tag, ##__VA_ARGS__); \
79#define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter format LOG_RESET_COLOR
81#define LOG_TAG(level, letter, tag, format, ...) \
84 if ((unsigned)level <= (unsigned)LOG_LEVEL) { \
85 printf(LOG_FORMAT(letter, format), ##__VA_ARGS__); \
90#define LOG_TAG_EARLY(level, letter, tag, format, ...) \
93 if ((unsigned)level <= (unsigned)LOG_LEVEL) { \
94 ets_printf(LOG_FORMAT(letter, format), ##__VA_ARGS__); \
104#ifndef MODULE_LOG_PRINTFNOFORMAT
109#define LOG_ERROR(format, ...) LOG_TAG(LOG_ERROR, E, __func__, format, ##__VA_ARGS__)
110#define LOG_WARNING(format, ...) LOG_TAG(LOG_WARNING, W, __func__, format, ##__VA_ARGS__)
111#define LOG_INFO(format, ...) LOG_TAG(LOG_INFO, I, __func__, format, ##__VA_ARGS__)
112#define LOG_DEBUG(format, ...) LOG_TAG(LOG_DEBUG, D, __func__, format, ##__VA_ARGS__)
116#define LOG_TAG_ERROR(tag, format, ...) LOG_TAG(LOG_ERROR, E, tag, format, ##__VA_ARGS__)
117#define LOG_TAG_WARNING(tag, format, ...) LOG_TAG(LOG_WARNING, W, tag, format, ##__VA_ARGS__)
118#define LOG_TAG_INFO(tag, format, ...) LOG_TAG(LOG_INFO, I, tag, format, ##__VA_ARGS__)
119#define LOG_TAG_DEBUG(tag, format, ...) LOG_TAG(LOG_DEBUG, D, tag, format, ##__VA_ARGS__)
120#define LOG_TAG_ALL(tag, format, ...) LOG_TAG(LOG_ALL, V, tag, format, ##__VA_ARGS__)
123#define ESP_EARLY_LOGE(tag, format, ...) LOG_TAG_EARLY(LOG_ERROR, E, tag, format "\n", ##__VA_ARGS__)
124#define ESP_EARLY_LOGW(tag, format, ...) LOG_TAG_EARLY(LOG_WARNING, W, tag, format "\n", ##__VA_ARGS__)
125#define ESP_EARLY_LOGI(tag, format, ...) LOG_TAG_EARLY(LOG_INFO, I, tag, format "\n", ##__VA_ARGS__)
126#define ESP_EARLY_LOGD(tag, format, ...) LOG_TAG_EARLY(LOG_DEBUG, D, tag, format "\n", ##__VA_ARGS__)
127#define ESP_EARLY_LOGV(tag, format, ...) LOG_TAG_EARLY(LOG_ALL, V, tag, format "\n", ##__VA_ARGS__)
130#define ESP_LOGE(tag, format, ...) LOG_TAG(LOG_ERROR, E, tag, format "\n", ##__VA_ARGS__)
131#define ESP_LOGW(tag, format, ...) LOG_TAG(LOG_WARNING, W, tag, format "\n", ##__VA_ARGS__)
132#define ESP_LOGI(tag, format, ...) LOG_TAG(LOG_INFO, I, tag, format "\n", ##__VA_ARGS__)
133#define ESP_LOGD(tag, format, ...) LOG_TAG(LOG_DEBUG, D, tag, format "\n", ##__VA_ARGS__)
134#define ESP_LOGV(tag, format, ...) LOG_TAG(LOG_ALL, V, tag, format "\n", ##__VA_ARGS__)
Adds include for missing inttype definitions.
stdio wrapper to extend the C libs stdio
uint32_t system_get_time_ms(void)
Time since boot in ms (32bit version)