esp_log.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * This is a STUB FILE HEADER used when compiling ESP-IDF to run tests on the host system.
  7. * The header file used normally for ESP-IDF has the same name but is located elsewhere.
  8. */
  9. #pragma once
  10. #include <stdint.h>
  11. #include <stdbool.h>
  12. #include <stdio.h>
  13. #include "sdkconfig.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #define heap_caps_malloc(a, b) NULL
  18. #define MALLOC_CAP_INTERNAL 0
  19. #define MALLOC_CAP_8BIT 0
  20. #define LOG_LOCAL_LEVEL CONFIG_LOG_DEFAULT_LEVEL
  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. #define LOG_COLOR_E
  30. #define LOG_COLOR_W
  31. #define LOG_COLOR_I
  32. #define LOG_COLOR_D
  33. #define LOG_COLOR_V
  34. #define LOG_RESET_COLOR
  35. #undef _Static_assert
  36. #define _Static_assert(cond, message)
  37. uint32_t esp_log_timestamp(void);
  38. void esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) __attribute__ ((format (printf, 3, 4)));
  39. #define LOG_FORMAT(letter, format) LOG_COLOR_ ## letter #letter " (%d) %s: " format LOG_RESET_COLOR "\n"
  40. #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__); }
  41. #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__); }
  42. #define ESP_LOGI( tag, format, ... ) if (LOG_LOCAL_LEVEL >= ESP_LOG_INFO) { esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
  43. #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__); }
  44. #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__); }
  45. #define esp_flash_encryption_enabled() false
  46. #ifdef __cplusplus
  47. }
  48. #endif