esp_log.h 2.5 KB

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