• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
15 #pragma once
16 #include "esp_rom_sys.h"
17 
18 /**
19  * @file soc_log.h
20  * @brief SOC library logging functions
21  *
22  * To make SOC library compatible with environments which don't use ESP-IDF,
23  * this header file provides wrappers for logging functions.
24  */
25 
26 #ifdef ESP_PLATFORM
27 #include "esp_log.h"
28 #define SOC_LOGE(tag, fmt, ...) ESP_EARLY_LOGE(tag, fmt, ##__VA_ARGS__)
29 #define SOC_LOGW(tag, fmt, ...) ESP_EARLY_LOGW(tag, fmt, ##__VA_ARGS__)
30 #define SOC_LOGI(tag, fmt, ...) ESP_EARLY_LOGI(tag, fmt, ##__VA_ARGS__)
31 #define SOC_LOGD(tag, fmt, ...) ESP_EARLY_LOGD(tag, fmt, ##__VA_ARGS__)
32 #define SOC_LOGV(tag, fmt, ...) ESP_EARLY_LOGV(tag, fmt, ##__VA_ARGS__)
33 
34 #else
35 #include "sdkconfig.h"
36 #ifdef CONFIG_IDF_TARGET_ESP32
37 #include "esp32/rom/ets_sys.h"  // will be removed in idf v5.0
38 #elif CONFIG_IDF_TARGET_ESP32S2
39 #include "esp32s2/rom/ets_sys.h"
40 #elif CONFIG_IDF_TARGET_ESP32S3
41 #include "esp32s3/rom/ets_sys.h"
42 #elif CONFIG_IDF_TARGET_ESP32C3
43 #include "esp32c3/rom/ets_sys.h"
44 #endif
45 
46 #define SOC_LOGE(tag, fmt, ...) esp_rom_printf("%s(err): " fmt, tag, ##__VA_ARGS__)
47 #define SOC_LOGW(tag, fmt, ...) esp_rom_printf("%s(warn): " fmt, tag, ##__VA_ARGS__)
48 #define SOC_LOGI(tag, fmt, ...) esp_rom_printf("%s(info): " fmt, tag, ##__VA_ARGS__)
49 #define SOC_LOGD(tag, fmt, ...) esp_rom_printf("%s(dbg): " fmt, tag, ##__VA_ARGS__)
50 #define SOC_LOGV(tag, fmt, ...) esp_rom_printf("%s: " fmt, tag, ##__VA_ARGS__)
51 #endif //ESP_PLATFORM
52