123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #ifndef __ESP_LOG_H__
- #define __ESP_LOG_H__
- #include <stdint.h>
- #include <stdarg.h>
- #include "esp_common.h"
- #define CONFIG_LOG_COLORS 1
- #define CONFIG_LOG_DEFAULT_LEVEL 100
- #define CPU_CLK_FREQ 80000000
- typedef enum {
- ESP_LOG_NONE,
- ESP_LOG_ERROR,
- ESP_LOG_WARN,
- ESP_LOG_INFO,
- ESP_LOG_DEBUG,
- ESP_LOG_VERBOSE
- } esp_log_level_t;
- uint32_t esp_log_timestamp(void);
- #if CONFIG_LOG_COLORS
- #define LOG_COLOR_BLACK "30"
- #define LOG_COLOR_RED "31"
- #define LOG_COLOR_GREEN "32"
- #define LOG_COLOR_BROWN "33"
- #define LOG_COLOR_BLUE "34"
- #define LOG_COLOR_PURPLE "35"
- #define LOG_COLOR_CYAN "36"
- #define LOG_COLOR(COLOR) "\033[0;" COLOR "m"
- #define LOG_BOLD(COLOR) "\033[1;" COLOR "m"
- #define LOG_RESET_COLOR "\033[0m"
- #define LOG_COLOR_E LOG_COLOR(LOG_COLOR_RED)
- #define LOG_COLOR_W LOG_COLOR(LOG_COLOR_BROWN)
- #define LOG_COLOR_I LOG_COLOR(LOG_COLOR_GREEN)
- #define LOG_COLOR_D
- #define LOG_COLOR_V
- #else
- #define LOG_COLOR_E
- #define LOG_COLOR_W
- #define LOG_COLOR_I
- #define LOG_COLOR_D
- #define LOG_COLOR_V
- #define LOG_RESET_COLOR
- #endif
- #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%d) %s: " format LOG_RESET_COLOR "\n"
- #define LOG_LOCAL_LEVEL ((esp_log_level_t) CONFIG_LOG_DEFAULT_LEVEL)
- #define ESP_LOGE( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) { os_printf(LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
- #define ESP_LOGW( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) { os_printf(LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
- #define ESP_LOGI( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { os_printf(LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
- #define ESP_LOGD( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { os_printf(LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
- #define ESP_LOGV( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) { os_printf(LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
- #endif
|