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 33enum HcfLogLevel { 34 HCF_LOG_LEVEL_I, 35 HCF_LOG_LEVEL_E, 36 HCF_LOG_LEVEL_W, 37 HCF_LOG_LEVEL_D, 38}; 39 40#ifdef __cplusplus 41extern "C" { 42#endif 43 44void HcfLogPrint(uint32_t hcfLogLevel, const char *funcName, uint32_t lineNo, const char *format, ...); 45 46#ifdef __cplusplus 47} 48#endif 49 50#undef LOG_TAG 51#define LOG_TAG "HCF" 52 53#undef LOG_DOMAIN 54#define LOG_DOMAIN 0xD002F0A /* Security subsystem's domain id */ 55 56#define LOGI(...) HcfLogPrint(HCF_LOG_LEVEL_I, __func__, __LINE__, __VA_ARGS__) 57#define LOGW(...) HcfLogPrint(HCF_LOG_LEVEL_W, __func__, __LINE__, __VA_ARGS__) 58#define LOGE(...) HcfLogPrint(HCF_LOG_LEVEL_E, __func__, __LINE__, __VA_ARGS__) 59#define LOGD(...) HcfLogPrint(HCF_LOG_LEVEL_D, __func__, __LINE__, __VA_ARGS__) 60#else 61 62#include <stdio.h> 63 64#define LOGD(fmt, ...) printf("[HCF][D][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 65#define LOGI(fmt, ...) printf("[HCF][I][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 66#define LOGW(fmt, ...) printf("[HCF][W][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 67#define LOGE(fmt, ...) printf("[HCF][E][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 68 69#endif 70#endif 71