1 /* 2 * Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #pragma once 8 9 #include "sdkconfig.h" 10 #include "mcuboot_config.h" 11 #include "esp_log.h" 12 13 extern int ets_printf(const char *fmt, ...); 14 15 #define MCUBOOT_LOG_LEVEL_OFF 0 16 #define MCUBOOT_LOG_LEVEL_ERROR 1 17 #define MCUBOOT_LOG_LEVEL_WARNING 2 18 #define MCUBOOT_LOG_LEVEL_INFO 3 19 #define MCUBOOT_LOG_LEVEL_DEBUG 4 20 21 #ifndef MCUBOOT_LOG_LEVEL 22 #define MCUBOOT_LOG_LEVEL MCUBOOT_LOG_LEVEL_INFO 23 #endif 24 25 #if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_ERROR 26 #define MCUBOOT_LOG_ERR(_fmt, ...) \ 27 do { \ 28 ESP_EARLY_LOGE("boot", _fmt, ##__VA_ARGS__); \ 29 } while (0) 30 #else 31 #define MCUBOOT_LOG_ERR(_fmt, ...) 32 #endif 33 34 #if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_WARNING 35 #define MCUBOOT_LOG_WRN(_fmt, ...) \ 36 do { \ 37 ESP_EARLY_LOGW("boot", _fmt, ##__VA_ARGS__); \ 38 } while (0) 39 #else 40 #define MCUBOOT_LOG_WRN(_fmt, ...) 41 #endif 42 43 #if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_INFO 44 #define MCUBOOT_LOG_INF(_fmt, ...) \ 45 do { \ 46 ESP_EARLY_LOGI("boot", _fmt, ##__VA_ARGS__); \ 47 } while (0) 48 #else 49 #define MCUBOOT_LOG_INF(_fmt, ...) 50 #endif 51 52 #if MCUBOOT_LOG_LEVEL >= MCUBOOT_LOG_LEVEL_DEBUG 53 #define MCUBOOT_LOG_DBG(_fmt, ...) \ 54 do { \ 55 ESP_EARLY_LOGD("boot", _fmt, ##__VA_ARGS__); \ 56 } while (0) 57 #else 58 #define MCUBOOT_LOG_DBG(_fmt, ...) 59 #endif 60 61 #define MCUBOOT_LOG_MODULE_DECLARE(...) 62 #define MCUBOOT_LOG_MODULE_REGISTER(...) 63