1 /* 2 * Copyright (C) 2022-2024 Huawei Device Co., Ltd. 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 16 #ifndef HCF_LOG_H 17 #define HCF_LOG_H 18 19 #include <stdint.h> 20 #include <stdlib.h> 21 22 #ifdef HILOG_ENABLE 23 24 enum HcfLogLevel { 25 HCF_LOG_LEVEL_I, 26 HCF_LOG_LEVEL_E, 27 HCF_LOG_LEVEL_W, 28 HCF_LOG_LEVEL_D, 29 }; 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 void HcfLogPrint(uint32_t hcfLogLevel, const char *funcName, uint32_t lineNo, const char *format, ...); 36 37 #ifdef __cplusplus 38 } 39 #endif 40 41 #undef LOG_TAG 42 #define LOG_TAG "HCF" 43 44 #undef LOG_DOMAIN 45 #define LOG_DOMAIN 0xD002F0A /* Security subsystem's domain id */ 46 47 #define LOGI(...) HcfLogPrint(HCF_LOG_LEVEL_I, __func__, __LINE__, __VA_ARGS__) 48 #define LOGW(...) HcfLogPrint(HCF_LOG_LEVEL_W, __func__, __LINE__, __VA_ARGS__) 49 #define LOGE(...) HcfLogPrint(HCF_LOG_LEVEL_E, __func__, __LINE__, __VA_ARGS__) 50 #define LOGD(...) HcfLogPrint(HCF_LOG_LEVEL_D, __func__, __LINE__, __VA_ARGS__) 51 #else 52 53 #include <stdio.h> 54 55 #define LOGD(fmt, ...) printf("[HCF][D][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 56 #define LOGI(fmt, ...) printf("[HCF][I][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 57 #define LOGW(fmt, ...) printf("[HCF][W][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 58 #define LOGE(fmt, ...) printf("[HCF][E][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 59 60 #endif 61 #endif 62