1 /* 2 * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 /** 10 * When compiling a G0 application, `log` component is not available, thus its headers (`esp_log.h`) and Kconfig macros 11 * are not available either. 12 * In that case, we have to define the LOG macros to use ROM functions, which are part of G0 layer. 13 */ 14 #if __has_include("esp_log.h") 15 16 #include "esp_log.h" 17 18 #define HAL_LOGE(...) ESP_LOGE(__VA_ARGS__) 19 #define HAL_LOGW(...) ESP_LOGW(__VA_ARGS__) 20 #define HAL_LOGI(...) ESP_LOGI(__VA_ARGS__) 21 #define HAL_LOGD(...) ESP_LOGD(__VA_ARGS__) 22 #define HAL_LOGV(...) ESP_LOGV(__VA_ARGS__) 23 24 #define HAL_EARLY_LOGE(...) ESP_EARLY_LOGE(__VA_ARGS__) 25 #define HAL_EARLY_LOGW(...) ESP_EARLY_LOGW(__VA_ARGS__) 26 #define HAL_EARLY_LOGI(...) ESP_EARLY_LOGI(__VA_ARGS__) 27 #define HAL_EARLY_LOGD(...) ESP_EARLY_LOGD(__VA_ARGS__) 28 #define HAL_EARLY_LOGV(...) ESP_EARLY_LOGV(__VA_ARGS__) 29 30 #else // __has_include("esp_log.h") 31 32 #include "esp_rom_sys.h" 33 34 #define HAL_LOG_NONE 0 35 #define HAL_LOG_ERROR 1 36 #define HAL_LOG_WARN 2 37 #define HAL_LOG_INFO 3 38 #define HAL_LOG_DEBUG 4 39 #define HAL_LOG_VERBOSE 5 40 41 42 #if CONFIG_HAL_LOG_LEVEL >= HAL_LOG_ERROR 43 #define HAL_LOGE(tag, fmt, ...) esp_rom_printf("%s(err): " fmt, tag, ##__VA_ARGS__) 44 #else 45 #define HAL_LOGE(tag, fmt, ...) 46 #endif 47 48 #if CONFIG_HAL_LOG_LEVEL >= HAL_LOG_WARN 49 #define HAL_LOGW(tag, fmt, ...) esp_rom_printf("%s(warn): " fmt, tag, ##__VA_ARGS__) 50 #else 51 #define HAL_LOGW(tag, fmt, ...) 52 #endif 53 54 #if CONFIG_HAL_LOG_LEVEL >= HAL_LOG_INFO 55 #define HAL_LOGI(tag, fmt, ...) esp_rom_printf("%s(info): " fmt, tag, ##__VA_ARGS__) 56 #else 57 #define HAL_LOGI(tag, fmt, ...) 58 #endif 59 60 #if CONFIG_HAL_LOG_LEVEL >= HAL_LOG_DEBUG 61 #define HAL_LOGD(tag, fmt, ...) esp_rom_printf("%s(dbg): " fmt, tag, ##__VA_ARGS__) 62 #else 63 #define HAL_LOGD(tag, fmt, ...) 64 #endif 65 66 #if CONFIG_HAL_LOG_LEVEL >= HAL_LOG_VERBOSE 67 #define HAL_LOGV(tag, fmt, ...) esp_rom_printf("%s: " fmt, tag, ##__VA_ARGS__) 68 #else 69 #define HAL_LOGV(tag, fmt, ...) 70 #endif 71 72 #define HAL_EARLY_LOGE(...) HAL_LOGE(__VA_ARGS__) 73 #define HAL_EARLY_LOGW(...) HAL_LOGW(__VA_ARGS__) 74 #define HAL_EARLY_LOGI(...) HAL_LOGI(__VA_ARGS__) 75 #define HAL_EARLY_LOGD(...) HAL_LOGD(__VA_ARGS__) 76 #define HAL_EARLY_LOGV(...) HAL_LOGV(__VA_ARGS__) 77 78 #endif // __has_include("esp_log.h") 79