1 #pragma once 2 3 #include <stdint.h> 4 #include <stdio.h> 5 6 #include "sdkconfig.h" 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #define strlcpy(a, b, c) 13 #define strlcat(a, b, c) 14 15 #define heap_caps_malloc(a, b) NULL 16 #define MALLOC_CAP_INTERNAL 0 17 #define MALLOC_CAP_8BIT 0 18 19 #define LOG_LOCAL_LEVEL CONFIG_LOG_DEFAULT_LEVEL 20 21 typedef enum { 22 ESP_LOG_NONE, /*!< No log output */ 23 ESP_LOG_ERROR, /*!< Critical errors, software module can not recover on its own */ 24 ESP_LOG_WARN, /*!< Error conditions from which recovery measures have been taken */ 25 ESP_LOG_INFO, /*!< Information messages which describe normal flow of events */ 26 ESP_LOG_DEBUG, /*!< Extra information which is not necessary for normal use (values, pointers, sizes, etc). */ 27 ESP_LOG_VERBOSE /*!< Bigger chunks of debugging information, or frequent messages which can potentially flood the output. */ 28 } esp_log_level_t; 29 30 #define LOG_COLOR_E 31 #define LOG_COLOR_W 32 #define LOG_COLOR_I 33 #define LOG_COLOR_D 34 #define LOG_COLOR_V 35 #define LOG_RESET_COLOR 36 37 #undef _Static_assert 38 #define _Static_assert(cond, message) 39 40 uint32_t esp_log_timestamp(void); 41 void esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) __attribute__ ((format (printf, 3, 4))); 42 43 #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%d) %s: " format LOG_RESET_COLOR "\r\n" 44 45 #define ESP_LOGE( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_ERROR) { esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } 46 47 #define ESP_LOGW( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_WARN) { esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } 48 49 #define ESP_LOGI( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } 50 51 #define ESP_LOGD( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_DEBUG) { esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } 52 53 #define ESP_LOGV( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_VERBOSE) { esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); } 54 55 // Assume that flash encryption is not enabled. Put here since in partition.c 56 // esp_log.h is included later than esp_flash_encrypt.h. 57 #define esp_flash_encryption_enabled() false 58 59 #ifdef __cplusplus 60 } 61 #endif 62