13f4cbf05Sopenharmony_ci/* 23f4cbf05Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 33f4cbf05Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 43f4cbf05Sopenharmony_ci * you may not use this file except in compliance with the License. 53f4cbf05Sopenharmony_ci * You may obtain a copy of the License at 63f4cbf05Sopenharmony_ci * 73f4cbf05Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 83f4cbf05Sopenharmony_ci * 93f4cbf05Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 103f4cbf05Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 113f4cbf05Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 123f4cbf05Sopenharmony_ci * See the License for the specific language governing permissions and 133f4cbf05Sopenharmony_ci * limitations under the License. 143f4cbf05Sopenharmony_ci */ 153f4cbf05Sopenharmony_ci#ifndef UTILS_BASE_LOG_H 163f4cbf05Sopenharmony_ci#define UTILS_BASE_LOG_H 173f4cbf05Sopenharmony_ci 183f4cbf05Sopenharmony_ci#ifdef CONFIG_HILOG 193f4cbf05Sopenharmony_ci#include "hilog_base/log_base.h" 203f4cbf05Sopenharmony_ciconstexpr LogType UTILS_LOG_TYPE = LOG_CORE; 213f4cbf05Sopenharmony_ciconstexpr unsigned int UTILS_LOG_DOMAIN = 0xD003D00; 223f4cbf05Sopenharmony_ciconstexpr const char *UTILS_LOG_TAG = "utils_base"; 233f4cbf05Sopenharmony_ci#define UTILS_LOGF(...) (void)HiLogBasePrint(UTILS_LOG_TYPE, LOG_FATAL, UTILS_LOG_DOMAIN, UTILS_LOG_TAG, __VA_ARGS__) 243f4cbf05Sopenharmony_ci#define UTILS_LOGE(...) (void)HiLogBasePrint(UTILS_LOG_TYPE, LOG_ERROR, UTILS_LOG_DOMAIN, UTILS_LOG_TAG, __VA_ARGS__) 253f4cbf05Sopenharmony_ci#define UTILS_LOGW(...) (void)HiLogBasePrint(UTILS_LOG_TYPE, LOG_WARN, UTILS_LOG_DOMAIN, UTILS_LOG_TAG, __VA_ARGS__) 263f4cbf05Sopenharmony_ci#define UTILS_LOGI(...) (void)HiLogBasePrint(UTILS_LOG_TYPE, LOG_INFO, UTILS_LOG_DOMAIN, UTILS_LOG_TAG, __VA_ARGS__) 273f4cbf05Sopenharmony_ci#ifdef DEBUG_UTILS 283f4cbf05Sopenharmony_ci#define UTILS_LOGD(...) (void)HiLogBasePrint(UTILS_LOG_TYPE, LOG_DEBUG, UTILS_LOG_DOMAIN, UTILS_LOG_TAG, __VA_ARGS__) 293f4cbf05Sopenharmony_ci#else 303f4cbf05Sopenharmony_ci#define UTILS_LOGD(...) 313f4cbf05Sopenharmony_ci#endif 323f4cbf05Sopenharmony_ci#else 333f4cbf05Sopenharmony_ci#define UTILS_LOGF(...) 343f4cbf05Sopenharmony_ci#define UTILS_LOGE(...) 353f4cbf05Sopenharmony_ci#define UTILS_LOGW(...) 363f4cbf05Sopenharmony_ci#define UTILS_LOGI(...) 373f4cbf05Sopenharmony_ci#define UTILS_LOGD(...) 383f4cbf05Sopenharmony_ci#endif // CONFIG_HILOG 393f4cbf05Sopenharmony_ci 403f4cbf05Sopenharmony_ci#if (defined CONFIG_HILOG) && (defined CONFIG_PARCEL_DEBUG) 413f4cbf05Sopenharmony_ciconstexpr LogType PARCEL_LOG_TYPE = LOG_CORE; 423f4cbf05Sopenharmony_ciconstexpr unsigned int PARCEL_LOG_DOMAIN = 0xD003D01; 433f4cbf05Sopenharmony_ciconstexpr const char *PARCEL_LOG_TAG = "parcel"; 443f4cbf05Sopenharmony_ci#define PARCEL_LOGF(...) \ 453f4cbf05Sopenharmony_ci (void)HiLogBasePrint(PARCEL_LOG_TYPE, LOG_FATAL, PARCEL_LOG_DOMAIN, PARCEL_LOG_TAG, __VA_ARGS__) 463f4cbf05Sopenharmony_ci#define PARCEL_LOGE(...) \ 473f4cbf05Sopenharmony_ci (void)HiLogBasePrint(PARCEL_LOG_TYPE, LOG_ERROR, PARCEL_LOG_DOMAIN, PARCEL_LOG_TAG, __VA_ARGS__) 483f4cbf05Sopenharmony_ci#define PARCEL_LOGW(...) \ 493f4cbf05Sopenharmony_ci (void)HiLogBasePrint(PARCEL_LOG_TYPE, LOG_WARN, PARCEL_LOG_DOMAIN, PARCEL_LOG_TAG, __VA_ARGS__) 503f4cbf05Sopenharmony_ci#define PARCEL_LOGI(...) \ 513f4cbf05Sopenharmony_ci (void)HiLogBasePrint(PARCEL_LOG_TYPE, LOG_INFO, PARCEL_LOG_DOMAIN, PARCEL_LOG_TAG, __VA_ARGS__) 523f4cbf05Sopenharmony_ci#define PARCEL_LOGD(...) \ 533f4cbf05Sopenharmony_ci (void)HiLogBasePrint(PARCEL_LOG_TYPE, LOG_DEBUG, PARCEL_LOG_DOMAIN, PARCEL_LOG_TAG, __VA_ARGS__) 543f4cbf05Sopenharmony_ci#else 553f4cbf05Sopenharmony_ci#define PARCEL_LOGF(...) 563f4cbf05Sopenharmony_ci#define PARCEL_LOGE(...) 573f4cbf05Sopenharmony_ci#define PARCEL_LOGW(...) 583f4cbf05Sopenharmony_ci#define PARCEL_LOGI(...) 593f4cbf05Sopenharmony_ci#define PARCEL_LOGD(...) 603f4cbf05Sopenharmony_ci#endif // (defined CONFIG_HILOG) && (defined CONFIG_PARCEL_DEBUG) 613f4cbf05Sopenharmony_ci 623f4cbf05Sopenharmony_ci#endif // UTILS_BASE_LOG_H 63