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