11b8d9b87Sopenharmony_ci/* 21b8d9b87Sopenharmony_ci * Copyright (C) 2022-2024 Huawei Device Co., Ltd. 31b8d9b87Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 41b8d9b87Sopenharmony_ci * you may not use this file except in compliance with the License. 51b8d9b87Sopenharmony_ci * You may obtain a copy of the License at 61b8d9b87Sopenharmony_ci * 71b8d9b87Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 81b8d9b87Sopenharmony_ci * 91b8d9b87Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 101b8d9b87Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 111b8d9b87Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 121b8d9b87Sopenharmony_ci * See the License for the specific language governing permissions and 131b8d9b87Sopenharmony_ci * limitations under the License. 141b8d9b87Sopenharmony_ci */ 151b8d9b87Sopenharmony_ci 161b8d9b87Sopenharmony_ci#ifndef HCF_LOG_H 171b8d9b87Sopenharmony_ci#define HCF_LOG_H 181b8d9b87Sopenharmony_ci 191b8d9b87Sopenharmony_ci#include <stdint.h> 201b8d9b87Sopenharmony_ci#include <stdlib.h> 211b8d9b87Sopenharmony_ci 221b8d9b87Sopenharmony_ci#if defined(MINI_HILOG_ENABLE) 231b8d9b87Sopenharmony_ci 241b8d9b87Sopenharmony_ci#include "hiview_log.h" 251b8d9b87Sopenharmony_ci 261b8d9b87Sopenharmony_ci#define LOGD(fmt, ...) HILOG_DEBUG(HILOG_MODULE_SCY, fmt, ##__VA_ARGS__) 271b8d9b87Sopenharmony_ci#define LOGI(fmt, ...) HILOG_INFO(HILOG_MODULE_SCY, fmt, ##__VA_ARGS__) 281b8d9b87Sopenharmony_ci#define LOGW(fmt, ...) HILOG_WARN(HILOG_MODULE_SCY, fmt, ##__VA_ARGS__) 291b8d9b87Sopenharmony_ci#define LOGE(fmt, ...) HILOG_ERROR(HILOG_MODULE_SCY, fmt, ##__VA_ARGS__) 301b8d9b87Sopenharmony_ci 311b8d9b87Sopenharmony_ci#elif defined(HILOG_ENABLE) 321b8d9b87Sopenharmony_ci 331b8d9b87Sopenharmony_cienum HcfLogLevel { 341b8d9b87Sopenharmony_ci HCF_LOG_LEVEL_I, 351b8d9b87Sopenharmony_ci HCF_LOG_LEVEL_E, 361b8d9b87Sopenharmony_ci HCF_LOG_LEVEL_W, 371b8d9b87Sopenharmony_ci HCF_LOG_LEVEL_D, 381b8d9b87Sopenharmony_ci}; 391b8d9b87Sopenharmony_ci 401b8d9b87Sopenharmony_ci#ifdef __cplusplus 411b8d9b87Sopenharmony_ciextern "C" { 421b8d9b87Sopenharmony_ci#endif 431b8d9b87Sopenharmony_ci 441b8d9b87Sopenharmony_civoid HcfLogPrint(uint32_t hcfLogLevel, const char *funcName, uint32_t lineNo, const char *format, ...); 451b8d9b87Sopenharmony_ci 461b8d9b87Sopenharmony_ci#ifdef __cplusplus 471b8d9b87Sopenharmony_ci} 481b8d9b87Sopenharmony_ci#endif 491b8d9b87Sopenharmony_ci 501b8d9b87Sopenharmony_ci#undef LOG_TAG 511b8d9b87Sopenharmony_ci#define LOG_TAG "HCF" 521b8d9b87Sopenharmony_ci 531b8d9b87Sopenharmony_ci#undef LOG_DOMAIN 541b8d9b87Sopenharmony_ci#define LOG_DOMAIN 0xD002F0A /* Security subsystem's domain id */ 551b8d9b87Sopenharmony_ci 561b8d9b87Sopenharmony_ci#define LOGI(...) HcfLogPrint(HCF_LOG_LEVEL_I, __func__, __LINE__, __VA_ARGS__) 571b8d9b87Sopenharmony_ci#define LOGW(...) HcfLogPrint(HCF_LOG_LEVEL_W, __func__, __LINE__, __VA_ARGS__) 581b8d9b87Sopenharmony_ci#define LOGE(...) HcfLogPrint(HCF_LOG_LEVEL_E, __func__, __LINE__, __VA_ARGS__) 591b8d9b87Sopenharmony_ci#define LOGD(...) HcfLogPrint(HCF_LOG_LEVEL_D, __func__, __LINE__, __VA_ARGS__) 601b8d9b87Sopenharmony_ci#else 611b8d9b87Sopenharmony_ci 621b8d9b87Sopenharmony_ci#include <stdio.h> 631b8d9b87Sopenharmony_ci 641b8d9b87Sopenharmony_ci#define LOGD(fmt, ...) printf("[HCF][D][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 651b8d9b87Sopenharmony_ci#define LOGI(fmt, ...) printf("[HCF][I][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 661b8d9b87Sopenharmony_ci#define LOGW(fmt, ...) printf("[HCF][W][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 671b8d9b87Sopenharmony_ci#define LOGE(fmt, ...) printf("[HCF][E][%s]: " fmt "\n", __FUNCTION__, ##__VA_ARGS__) 681b8d9b87Sopenharmony_ci 691b8d9b87Sopenharmony_ci#endif 701b8d9b87Sopenharmony_ci#endif 71