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 #if defined(MINI_HILOG_ENABLE) 23 24 #include "hiview_log.h" 25 26 #define LOGD(fmt, ...) HILOG_DEBUG(HILOG_MODULE_SCY, fmt, ##__VA_ARGS__) 27 #define LOGI(fmt, ...) HILOG_INFO(HILOG_MODULE_SCY, fmt, ##__VA_ARGS__) 28 #define LOGW(fmt, ...) HILOG_WARN(HILOG_MODULE_SCY, fmt, ##__VA_ARGS__) 29 #define LOGE(fmt, ...) HILOG_ERROR(HILOG_MODULE_SCY, fmt, ##__VA_ARGS__) 30 31 #elif defined(HILOG_ENABLE) 32 33 #include "hilog/log.h" 34 35 #ifdef __cplusplus 36 extern "C" { 37 #endif 38 39 #ifdef __cplusplus 40 } 41 #endif 42 43 #undef LOG_TAG 44 #define LOG_TAG "HCF" 45 46 #undef LOG_DOMAIN 47 #define LOG_DOMAIN 0xD002F0A /* Security subsystem's domain id */ 48 49 #define LOGI(fmt, ...) HILOG_INFO(LOG_CORE, "%{public}s[%{public}u]: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__) 50 #define LOGW(fmt, ...) HILOG_WARN(LOG_CORE, "%{public}s[%{public}u]: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__) 51 #define LOGE(fmt, ...) HILOG_ERROR(LOG_CORE, "%{public}s[%{public}u]: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__) 52 #define LOGD(fmt, ...) HILOG_DEBUG(LOG_CORE, "%{public}s[%{public}u]: " fmt "\n", __func__, __LINE__, ##__VA_ARGS__) 53 #else 54 55 #include <stdio.h> 56 57 #define LOGD(fmt, ...) printf("[HCF][D][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 58 #define LOGI(fmt, ...) printf("[HCF][I][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 59 #define LOGW(fmt, ...) printf("[HCF][W][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 60 #define LOGE(fmt, ...) printf("[HCF][E][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 61 62 #endif 63 #endif 64