1 /*
2  * SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 #include "esp_rom_sys.h"
9 
10 /**
11  * @file soc_log.h
12  * @brief SOC library logging functions
13  *
14  * To make SOC library compatible with environments which don't use ESP-IDF,
15  * this header file provides wrappers for logging functions.
16  */
17 
18 #ifdef ESP_PLATFORM
19 #include "esp_log.h"
20 #define SOC_LOGE(tag, fmt, ...) ESP_EARLY_LOGE(tag, fmt, ##__VA_ARGS__)
21 #define SOC_LOGW(tag, fmt, ...) ESP_EARLY_LOGW(tag, fmt, ##__VA_ARGS__)
22 #define SOC_LOGI(tag, fmt, ...) ESP_EARLY_LOGI(tag, fmt, ##__VA_ARGS__)
23 #define SOC_LOGD(tag, fmt, ...) ESP_EARLY_LOGD(tag, fmt, ##__VA_ARGS__)
24 #define SOC_LOGV(tag, fmt, ...) ESP_EARLY_LOGV(tag, fmt, ##__VA_ARGS__)
25 
26 #else
27 #include "sdkconfig.h"
28 #ifdef CONFIG_IDF_TARGET_ESP32
29 #include "esp32/rom/ets_sys.h"  // will be removed in idf v5.0
30 #elif CONFIG_IDF_TARGET_ESP32S2
31 #include "esp32s2/rom/ets_sys.h"
32 #elif CONFIG_IDF_TARGET_ESP32S3
33 #include "esp32s3/rom/ets_sys.h"
34 #elif CONFIG_IDF_TARGET_ESP32C3
35 #include "esp32c3/rom/ets_sys.h"
36 #elif CONFIG_IDF_TARGET_ESP32H2
37 #include "esp32h2/rom/ets_sys.h"
38 #endif
39 
40 #define SOC_LOGE(tag, fmt, ...) esp_rom_printf("%s(err): " fmt, tag, ##__VA_ARGS__)
41 #define SOC_LOGW(tag, fmt, ...) esp_rom_printf("%s(warn): " fmt, tag, ##__VA_ARGS__)
42 #define SOC_LOGI(tag, fmt, ...) esp_rom_printf("%s(info): " fmt, tag, ##__VA_ARGS__)
43 #define SOC_LOGD(tag, fmt, ...) esp_rom_printf("%s(dbg): " fmt, tag, ##__VA_ARGS__)
44 #define SOC_LOGV(tag, fmt, ...) esp_rom_printf("%s: " fmt, tag, ##__VA_ARGS__)
45 #endif //ESP_PLATFORM
46