1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci 16094332d3Sopenharmony_ci#ifndef DISPLAY_LOG_H 17094332d3Sopenharmony_ci#define DISPLAY_LOG_H 18094332d3Sopenharmony_ci#include <stdint.h> 19094332d3Sopenharmony_ci#include <string.h> 20094332d3Sopenharmony_ci#include "hilog/log.h" 21094332d3Sopenharmony_ci 22094332d3Sopenharmony_ci#ifdef HDF_LOG_TAG 23094332d3Sopenharmony_ci#undef HDF_LOG_TAG 24094332d3Sopenharmony_ci#endif 25094332d3Sopenharmony_ci 26094332d3Sopenharmony_ci#if defined(__cplusplus) 27094332d3Sopenharmony_ciextern "C" { 28094332d3Sopenharmony_ci#endif 29094332d3Sopenharmony_ci 30094332d3Sopenharmony_ci#undef LOG_TAG 31094332d3Sopenharmony_ci#define LOG_TAG "DISP" 32094332d3Sopenharmony_ci#undef LOG_DOMAIN 33094332d3Sopenharmony_ci#define LOG_DOMAIN 0xD002515 34094332d3Sopenharmony_ci 35094332d3Sopenharmony_ci#ifndef DISPLAY_UNUSED 36094332d3Sopenharmony_ci#define DISPLAY_UNUSED(x) (void)(x) 37094332d3Sopenharmony_ci#endif 38094332d3Sopenharmony_ci 39094332d3Sopenharmony_ci#ifndef DISPLAY_DEBUG_ENABLE 40094332d3Sopenharmony_ci#define DISPLAY_DEBUG_ENABLE 1 41094332d3Sopenharmony_ci#endif 42094332d3Sopenharmony_ci 43094332d3Sopenharmony_ci#ifndef DISPLAY_LOGD 44094332d3Sopenharmony_ci#define DISPLAY_LOGD(format, ...) \ 45094332d3Sopenharmony_ci do { \ 46094332d3Sopenharmony_ci if (DISPLAY_DEBUG_ENABLE) { \ 47094332d3Sopenharmony_ci HILOG_DEBUG(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 48094332d3Sopenharmony_ci } \ 49094332d3Sopenharmony_ci } while (0) 50094332d3Sopenharmony_ci#endif 51094332d3Sopenharmony_ci 52094332d3Sopenharmony_ci#ifndef DISPLAY_LOGI 53094332d3Sopenharmony_ci#define DISPLAY_LOGI(format, ...) \ 54094332d3Sopenharmony_ci do { \ 55094332d3Sopenharmony_ci HILOG_INFO(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 56094332d3Sopenharmony_ci } while (0) 57094332d3Sopenharmony_ci#endif 58094332d3Sopenharmony_ci 59094332d3Sopenharmony_ci#ifndef DISPLAY_LOGW 60094332d3Sopenharmony_ci#define DISPLAY_LOGW(format, ...) \ 61094332d3Sopenharmony_ci do { \ 62094332d3Sopenharmony_ci HILOG_WARN(LOG_CORE, "[%{public}s:%{public}d] " format "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 63094332d3Sopenharmony_ci } while (0) 64094332d3Sopenharmony_ci#endif 65094332d3Sopenharmony_ci 66094332d3Sopenharmony_ci#ifndef DISPLAY_LOGE 67094332d3Sopenharmony_ci#define DISPLAY_LOGE(format, ...) \ 68094332d3Sopenharmony_ci do { \ 69094332d3Sopenharmony_ci HILOG_ERROR(LOG_CORE, \ 70094332d3Sopenharmony_ci "\033[0;32;31m" \ 71094332d3Sopenharmony_ci "[%{public}s:%{public}d] " format "\033[m" \ 72094332d3Sopenharmony_ci "\n", \ 73094332d3Sopenharmony_ci __FUNCTION__, __LINE__, ##__VA_ARGS__); \ 74094332d3Sopenharmony_ci } while (0) 75094332d3Sopenharmony_ci#endif 76094332d3Sopenharmony_ci 77094332d3Sopenharmony_ci#ifndef CHECK_NULLPOINTER_RETURN_VALUE 78094332d3Sopenharmony_ci#define CHECK_NULLPOINTER_RETURN_VALUE(pointer, ret) \ 79094332d3Sopenharmony_ci do { \ 80094332d3Sopenharmony_ci if ((pointer) == NULL) { \ 81094332d3Sopenharmony_ci DISPLAY_LOGE("pointer is null and return ret\n"); \ 82094332d3Sopenharmony_ci return (ret); \ 83094332d3Sopenharmony_ci } \ 84094332d3Sopenharmony_ci } while (0) 85094332d3Sopenharmony_ci#endif 86094332d3Sopenharmony_ci 87094332d3Sopenharmony_ci#ifndef CHECK_NULLPOINTER_RETURN 88094332d3Sopenharmony_ci#define CHECK_NULLPOINTER_RETURN(pointer) \ 89094332d3Sopenharmony_ci do { \ 90094332d3Sopenharmony_ci if ((pointer) == NULL) { \ 91094332d3Sopenharmony_ci DISPLAY_LOGE("pointer is null and return\n"); \ 92094332d3Sopenharmony_ci return; \ 93094332d3Sopenharmony_ci } \ 94094332d3Sopenharmony_ci } while (0) 95094332d3Sopenharmony_ci#endif 96094332d3Sopenharmony_ci 97094332d3Sopenharmony_ci#ifndef DISPLAY_CHK_RETURN 98094332d3Sopenharmony_ci#define DISPLAY_CHK_RETURN(val, ret, ...) \ 99094332d3Sopenharmony_ci do { \ 100094332d3Sopenharmony_ci if (val) { \ 101094332d3Sopenharmony_ci __VA_ARGS__; \ 102094332d3Sopenharmony_ci return (ret); \ 103094332d3Sopenharmony_ci } \ 104094332d3Sopenharmony_ci } while (0) 105094332d3Sopenharmony_ci#endif 106094332d3Sopenharmony_ci 107094332d3Sopenharmony_ci#ifndef DISPLAY_CHK_RETURN_NOT_VALUE 108094332d3Sopenharmony_ci#define DISPLAY_CHK_RETURN_NOT_VALUE(val, ...) \ 109094332d3Sopenharmony_ci do { \ 110094332d3Sopenharmony_ci if (val) { \ 111094332d3Sopenharmony_ci __VA_ARGS__; \ 112094332d3Sopenharmony_ci return; \ 113094332d3Sopenharmony_ci } \ 114094332d3Sopenharmony_ci } while (0) 115094332d3Sopenharmony_ci#endif 116094332d3Sopenharmony_ci 117094332d3Sopenharmony_ci#ifdef __cplusplus 118094332d3Sopenharmony_ci} 119094332d3Sopenharmony_ci#endif 120094332d3Sopenharmony_ci 121094332d3Sopenharmony_ci#endif // DISPLAY_LOG_H 122