7 #ifdef USE_STORE_LOG_STR_IN_FLASH 13 #if defined(USE_ESP32_FRAMEWORK_ARDUINO) || defined(USE_ESP_IDF) 17 #ifdef USE_ESP32_FRAMEWORK_ARDUINO 18 #include <esp32-hal-log.h> 21 #include <lt_logger.h> 26 #define ESPHOME_LOG_LEVEL_NONE 0 27 #define ESPHOME_LOG_LEVEL_ERROR 1 28 #define ESPHOME_LOG_LEVEL_WARN 2 29 #define ESPHOME_LOG_LEVEL_INFO 3 30 #define ESPHOME_LOG_LEVEL_CONFIG 4 31 #define ESPHOME_LOG_LEVEL_DEBUG 5 32 #define ESPHOME_LOG_LEVEL_VERBOSE 6 33 #define ESPHOME_LOG_LEVEL_VERY_VERBOSE 7 35 #ifndef ESPHOME_LOG_LEVEL 36 #define ESPHOME_LOG_LEVEL ESPHOME_LOG_LEVEL_NONE 39 #define ESPHOME_LOG_COLOR_BLACK "30" 40 #define ESPHOME_LOG_COLOR_RED "31" // ERROR 41 #define ESPHOME_LOG_COLOR_GREEN "32" // INFO 42 #define ESPHOME_LOG_COLOR_YELLOW "33" // WARNING 43 #define ESPHOME_LOG_COLOR_BLUE "34" 44 #define ESPHOME_LOG_COLOR_MAGENTA "35" // CONFIG 45 #define ESPHOME_LOG_COLOR_CYAN "36" // DEBUG 46 #define ESPHOME_LOG_COLOR_GRAY "37" // VERBOSE 47 #define ESPHOME_LOG_COLOR_WHITE "38" 48 #define ESPHOME_LOG_SECRET_BEGIN "\033[5m" 49 #define ESPHOME_LOG_SECRET_END "\033[6m" 50 #define LOG_SECRET(x) ESPHOME_LOG_SECRET_BEGIN x ESPHOME_LOG_SECRET_END 52 #define ESPHOME_LOG_COLOR(COLOR) "\033[0;" COLOR "m" 53 #define ESPHOME_LOG_BOLD(COLOR) "\033[1;" COLOR "m" 54 #define ESPHOME_LOG_RESET_COLOR "\033[0m" 56 void esp_log_printf_(
int level,
const char *tag,
int line,
const char *format, ...)
58 #ifdef USE_STORE_LOG_STR_IN_FLASH 59 void esp_log_printf_(
int level,
const char *tag,
int line,
const __FlashStringHelper *format, ...);
61 void esp_log_vprintf_(
int level,
const char *tag,
int line,
const char *format, va_list args);
62 #ifdef USE_STORE_LOG_STR_IN_FLASH 63 void esp_log_vprintf_(
int level,
const char *tag,
int line,
const __FlashStringHelper *format, va_list args);
65 #if defined(USE_ESP32_FRAMEWORK_ARDUINO) || defined(USE_ESP_IDF) 69 #ifdef USE_STORE_LOG_STR_IN_FLASH 70 #define ESPHOME_LOG_FORMAT(format) F(format) 72 #define ESPHOME_LOG_FORMAT(format) format 75 #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERY_VERBOSE 76 #define esph_log_vv(tag, format, ...) \ 77 esp_log_printf_(ESPHOME_LOG_LEVEL_VERY_VERBOSE, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) 79 #define ESPHOME_LOG_HAS_VERY_VERBOSE 81 #define esph_log_vv(tag, format, ...) 84 #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE 85 #define esph_log_v(tag, format, ...) \ 86 esp_log_printf_(ESPHOME_LOG_LEVEL_VERBOSE, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) 88 #define ESPHOME_LOG_HAS_VERBOSE 90 #define esph_log_v(tag, format, ...) 93 #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG 94 #define esph_log_d(tag, format, ...) \ 95 esp_log_printf_(ESPHOME_LOG_LEVEL_DEBUG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) 96 #define esph_log_config(tag, format, ...) \ 97 esp_log_printf_(ESPHOME_LOG_LEVEL_CONFIG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) 99 #define ESPHOME_LOG_HAS_DEBUG 100 #define ESPHOME_LOG_HAS_CONFIG 102 #define esph_log_d(tag, format, ...) 103 #define esph_log_config(tag, format, ...) 106 #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_INFO 107 #define esph_log_i(tag, format, ...) \ 108 esp_log_printf_(ESPHOME_LOG_LEVEL_INFO, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) 110 #define ESPHOME_LOG_HAS_INFO 112 #define esph_log_i(tag, format, ...) 115 #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_WARN 116 #define esph_log_w(tag, format, ...) \ 117 esp_log_printf_(ESPHOME_LOG_LEVEL_WARN, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) 119 #define ESPHOME_LOG_HAS_WARN 121 #define esph_log_w(tag, format, ...) 124 #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_ERROR 125 #define esph_log_e(tag, format, ...) \ 126 esp_log_printf_(ESPHOME_LOG_LEVEL_ERROR, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__) 128 #define ESPHOME_LOG_HAS_ERROR 130 #define esph_log_e(tag, format, ...) 149 #define ESP_LOGE(tag, ...) esph_log_e(tag, __VA_ARGS__) 150 #define ESP_LOGW(tag, ...) esph_log_w(tag, __VA_ARGS__) 151 #define ESP_LOGI(tag, ...) esph_log_i(tag, __VA_ARGS__) 152 #define ESP_LOGD(tag, ...) esph_log_d(tag, __VA_ARGS__) 153 #define ESP_LOGCONFIG(tag, ...) esph_log_config(tag, __VA_ARGS__) 154 #define ESP_LOGV(tag, ...) esph_log_v(tag, __VA_ARGS__) 155 #define ESP_LOGVV(tag, ...) esph_log_vv(tag, __VA_ARGS__) 157 #define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c" 158 #define BYTE_TO_BINARY(byte) \ 159 ((byte) &0x80 ? '1' : '0'), ((byte) &0x40 ? '1' : '0'), ((byte) &0x20 ? '1' : '0'), ((byte) &0x10 ? '1' : '0'), \ 160 ((byte) &0x08 ? '1' : '0'), ((byte) &0x04 ? '1' : '0'), ((byte) &0x02 ? '1' : '0'), ((byte) &0x01 ? '1' : '0') 161 #define YESNO(b) ((b) ? "YES" : "NO") 162 #define ONOFF(b) ((b) ? "ON" : "OFF") 163 #define TRUEFALSE(b) ((b) ? "TRUE" : "FALSE") 168 #ifdef USE_STORE_LOG_STR_IN_FLASH 170 #include <pgmspace.h> 172 #if USE_ARDUINO_VERSION_CODE >= VERSION_CODE(2, 5, 0) 173 #define LOG_STR_ARG(s) ((PGM_P) (s)) 178 #define LOG_STR_ARG(s) \ 182 strncpy_P(__buf, (PGM_P) (s), 63); \ 187 #define LOG_STR(s) (reinterpret_cast<const LogString *>(PSTR(s))) 188 #define LOG_STR_LITERAL(s) LOG_STR_ARG(LOG_STR(s)) 190 #else // !USE_STORE_LOG_STR_IN_FLASH 192 #define LOG_STR(s) (reinterpret_cast<const LogString *>(s)) 193 #define LOG_STR_ARG(s) (reinterpret_cast<const char *>(s)) 194 #define LOG_STR_LITERAL(s) (s) void HOT esp_log_vprintf_(int level, const char *tag, int line, const char *format, va_list args)
enum esphome::EntityCategory __attribute__
void HOT esp_log_printf_(int level, const char *tag, int line, const char *format,...)
Implementation of SPI Controller mode.
int HOT esp_idf_log_vprintf_(const char *format, va_list args)