1 /* 2 * Copyright (c) 2023 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 CF_LOG_H 17 #define CF_LOG_H 18 19 #include <stdint.h> 20 #include <stdlib.h> 21 22 #ifdef HILOG_ENABLE 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 #ifdef __cplusplus 29 } 30 #endif 31 32 #include "hilog/log.h" 33 34 #undef LOG_TAG 35 #define LOG_TAG "CertFramework" 36 #undef LOG_DOMAIN 37 #define LOG_DOMAIN 0xD002F17 /* CertFramework's domain id */ 38 39 #define CF_LOG_D(fmt, ...) \ 40 HILOG_DEBUG(LOG_CORE, "%{public}s[%{public}u]: " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) 41 #define CF_LOG_I(fmt, ...) \ 42 HILOG_INFO(LOG_CORE, "%{public}s[%{public}u]: " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) 43 #define CF_LOG_W(fmt, ...) \ 44 HILOG_WARN(LOG_CORE, "%{public}s[%{public}u]: " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) 45 #define CF_LOG_E(fmt, ...) \ 46 HILOG_ERROR(LOG_CORE, "%{public}s[%{public}u]: " fmt "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__) 47 48 #else 49 50 #include <stdio.h> 51 52 #define CF_LOG_D(fmt, ...) printf("[CertificateFramework][D][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 53 #define CF_LOG_I(fmt, ...) printf("[CertificateFramework][I][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 54 #define CF_LOG_W(fmt, ...) printf("[CertificateFramework][W][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 55 #define CF_LOG_E(fmt, ...) printf("[CertificateFramework][E][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 56 57 #endif 58 59 #define LOGD CF_LOG_D 60 #define LOGI CF_LOG_I 61 #define LOGW CF_LOG_W 62 #define LOGE CF_LOG_E 63 64 #endif 65