1/* 2 * Copyright (c) 2021-2023 Shenzhen Kaihong DID 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 CODEC_LOG_WRAPPER_H 17#define CODEC_LOG_WRAPPER_H 18#include <hdf_log.h> 19 20#ifdef __cplusplus 21extern "C" { 22#endif 23 24#ifdef LOG_DOMAIN 25#undef LOG_DOMAIN 26#endif 27#define LOG_DOMAIN 0xD002514 28 29#ifdef HDF_LOG_TAG 30#undef HDF_LOG_TAG 31#endif 32 33#ifdef LOG_TAG_IMAGE 34#define HDF_LOG_TAG codec_hdi_image 35#elif LOG_TAG_PASSTHROUGH 36#define HDF_LOG_TAG codec_hdi_adapter 37#elif LOG_TAG_HDI_SERVER 38#define HDF_LOG_TAG codec_hdi_server 39#elif LOG_TAG_HDI_CLIENT 40#define HDF_LOG_TAG codec_hdi_client 41#else 42#define HDF_LOG_TAG codec_hdi_omx 43#endif 44 45#define FILENAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 46 47#ifndef OHOS_DEBUG 48#define DECORATOR_HDFLOG(op, fmt, args...) \ 49 do { \ 50 op("%{public}s() " fmt, __FUNCTION__, ##args); \ 51 } while (0) 52#else 53#define DECORATOR_HDFLOG(op, fmt, args...) \ 54 do { \ 55 op("{%s()-%s:%d} " fmt, __FUNCTION__, FILENAME, __LINE__, ##args); \ 56 } while (0) 57#endif 58 59#define CODEC_LOGE(fmt, ...) DECORATOR_HDFLOG(HDF_LOGE, fmt, ##__VA_ARGS__) 60#define CODEC_LOGW(fmt, ...) DECORATOR_HDFLOG(HDF_LOGW, fmt, ##__VA_ARGS__) 61#define CODEC_LOGI(fmt, ...) DECORATOR_HDFLOG(HDF_LOGI, fmt, ##__VA_ARGS__) 62#define CODEC_LOGV(fmt, ...) DECORATOR_HDFLOG(HDF_LOGV, fmt, ##__VA_ARGS__) 63#define CODEC_LOGD(fmt, ...) DECORATOR_HDFLOG(HDF_LOGD, fmt, ##__VA_ARGS__) 64 65#define CHECK_AND_RETURN_RET_LOG(cond, ret, fmt, ...) \ 66do { \ 67if (!(cond)) { \ 68CODEC_LOGE(fmt, ##__VA_ARGS__); \ 69return ret; \ 70} \ 71} while (0) 72 73#ifdef __cplusplus 74} 75#endif 76#endif /* CODEC_LOG_WRAPPER_H */ 77