soc_log.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2016-2017 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include "esp_rom_sys.h"
  16. /**
  17. * @file soc_log.h
  18. * @brief SOC library logging functions
  19. *
  20. * To make SOC library compatible with environments which don't use ESP-IDF,
  21. * this header file provides wrappers for logging functions.
  22. */
  23. #ifdef ESP_PLATFORM
  24. #include "esp_log.h"
  25. #define SOC_LOGE(tag, fmt, ...) ESP_EARLY_LOGE(tag, fmt, ##__VA_ARGS__)
  26. #define SOC_LOGW(tag, fmt, ...) ESP_EARLY_LOGW(tag, fmt, ##__VA_ARGS__)
  27. #define SOC_LOGI(tag, fmt, ...) ESP_EARLY_LOGI(tag, fmt, ##__VA_ARGS__)
  28. #define SOC_LOGD(tag, fmt, ...) ESP_EARLY_LOGD(tag, fmt, ##__VA_ARGS__)
  29. #define SOC_LOGV(tag, fmt, ...) ESP_EARLY_LOGV(tag, fmt, ##__VA_ARGS__)
  30. #else
  31. #include "sdkconfig.h"
  32. #ifdef CONFIG_IDF_TARGET_ESP32
  33. #include "esp32/rom/ets_sys.h" // will be removed in idf v5.0
  34. #elif CONFIG_IDF_TARGET_ESP32S2
  35. #include "esp32s2/rom/ets_sys.h"
  36. #elif CONFIG_IDF_TARGET_ESP32S3
  37. #include "esp32s3/rom/ets_sys.h"
  38. #elif CONFIG_IDF_TARGET_ESP32C3
  39. #include "esp32c3/rom/ets_sys.h"
  40. #endif
  41. #define SOC_LOGE(tag, fmt, ...) esp_rom_printf("%s(err): " fmt, tag, ##__VA_ARGS__)
  42. #define SOC_LOGW(tag, fmt, ...) esp_rom_printf("%s(warn): " fmt, tag, ##__VA_ARGS__)
  43. #define SOC_LOGI(tag, fmt, ...) esp_rom_printf("%s(info): " fmt, tag, ##__VA_ARGS__)
  44. #define SOC_LOGD(tag, fmt, ...) esp_rom_printf("%s(dbg): " fmt, tag, ##__VA_ARGS__)
  45. #define SOC_LOGV(tag, fmt, ...) esp_rom_printf("%s: " fmt, tag, ##__VA_ARGS__)
  46. #endif //ESP_PLATFORM