1 /* 2 * Copyright (C) 2025 Huawei Device 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 FRAMEWORKS_ANI_SRC_INCLUDE_MEDIALIBRARY_ANI_LOG_H 17 #define FRAMEWORKS_ANI_SRC_INCLUDE_MEDIALIBRARY_ANI_LOG_H 18 19 #undef LOG_DOMAIN 20 #define LOG_DOMAIN 0xD002B71 21 22 #ifndef MLOG_TAG 23 #define MLOG_TAG "Common" 24 #endif 25 26 #undef LOG_TAG 27 #define LOG_TAG "MediaLibraryAni" 28 29 #ifndef LOG_LABEL 30 #define LOG_LABEL { LOG_CORE, LOG_DOMAIN, LOG_TAG } 31 #endif 32 33 #include "hilog/log.h" 34 35 #define FILE_NAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 36 37 #define ANI_HILOG(op, type, fmt, args...) \ 38 do { \ 39 op(LOG_CORE, type, LOG_DOMAIN, LOG_TAG, MLOG_TAG ":{%{public}s:%{public}d} " fmt, __FUNCTION__, __LINE__, \ 40 ##args); \ 41 } while (0) 42 43 #define ANI_DEBUG_LOG(fmt, ...) ANI_HILOG(HILOG_IMPL, LOG_DEBUG, fmt, ##__VA_ARGS__) 44 #define ANI_ERR_LOG(fmt, ...) ANI_HILOG(HILOG_IMPL, LOG_ERROR, fmt, ##__VA_ARGS__) 45 #define ANI_WARN_LOG(fmt, ...) ANI_HILOG(HILOG_IMPL, LOG_WARN, fmt, ##__VA_ARGS__) 46 #define ANI_INFO_LOG(fmt, ...) ANI_HILOG(HILOG_IMPL, LOG_INFO, fmt, ##__VA_ARGS__) 47 #define ANI_FATAL_LOG(fmt, ...) ANI_HILOG(HILOG_IMPL, LOG_FATAL, fmt, ##__VA_ARGS__) 48 49 #define ANI_CHECK_RETURN_RET_LOG(cond, ret, fmt, ...) \ 50 do { \ 51 if (!(cond)) { \ 52 ANI_ERR_LOG(fmt, ##__VA_ARGS__); \ 53 return ret; \ 54 } \ 55 } while (0) 56 57 #define ANI_CHECK_RETURN_LOG(cond, fmt, ...) \ 58 do { \ 59 if (!(cond)) { \ 60 ANI_ERR_LOG(fmt, ##__VA_ARGS__); \ 61 return; \ 62 } \ 63 } while (0) 64 65 #define ANI_CHECK_PRINT_LOG(cond, fmt, ...) \ 66 do { \ 67 if (!(cond)) { \ 68 ANI_ERR_LOG(fmt, ##__VA_ARGS__); \ 69 } \ 70 } while (0) 71 72 #define ANI_CHECK_WARN_LOG(cond, fmt, ...) \ 73 do { \ 74 if (!(cond)) { \ 75 ANI_WARN_LOG(fmt, ##__VA_ARGS__); \ 76 } \ 77 } while (0) 78 79 #define ANI_CHECK_RETURN_RET(cond, ret) \ 80 do { \ 81 if (!(cond)) { \ 82 return ret; \ 83 } \ 84 } while (0) 85 86 #endif // FRAMEWORKS_ANI_SRC_INCLUDE_MEDIALIBRARY_ANI_LOG_H