1 /* 2 * Copyright (C) 2021 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 INTERFACES_INNERKITS_NATIVE_INCLUDE_MEDIA_LOG_H_ 17 #define INTERFACES_INNERKITS_NATIVE_INCLUDE_MEDIA_LOG_H_ 18 19 #ifndef MLOG_TAG 20 #define MLOG_TAG "Common" 21 #endif 22 23 #undef LOG_DOMAIN 24 #define LOG_DOMAIN 0xD002B70 25 26 #undef LOG_TAG 27 #define LOG_TAG "MediaLibrary" 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 MEDIA_HILOG(op, type, fmt, args...) \ 36 do { \ 37 op(LOG_CORE, type, LOG_DOMAIN, LOG_TAG, MLOG_TAG ":{%{public}s:%{public}d} " fmt, __FUNCTION__, __LINE__, \ 38 ##args); \ 39 } while (0) 40 41 #define MEDIA_DEBUG_LOG(fmt, ...) MEDIA_HILOG(HILOG_IMPL, LOG_DEBUG, fmt, ##__VA_ARGS__) 42 #define MEDIA_ERR_LOG(fmt, ...) MEDIA_HILOG(HILOG_IMPL, LOG_ERROR, fmt, ##__VA_ARGS__) 43 #define MEDIA_WARN_LOG(fmt, ...) MEDIA_HILOG(HILOG_IMPL, LOG_WARN, fmt, ##__VA_ARGS__) 44 #define MEDIA_INFO_LOG(fmt, ...) MEDIA_HILOG(HILOG_IMPL, LOG_INFO, fmt, ##__VA_ARGS__) 45 #define MEDIA_FATAL_LOG(fmt, ...) MEDIA_HILOG(HILOG_IMPL, LOG_FATAL, fmt, ##__VA_ARGS__) 46 47 #define CHECK_AND_RETURN_RET_LOG(cond, ret, fmt, ...) \ 48 do { \ 49 if (!(cond)) { \ 50 MEDIA_ERR_LOG(fmt, ##__VA_ARGS__); \ 51 return ret; \ 52 } \ 53 } while (0) 54 55 #define CHECK_AND_RETURN_LOG(cond, fmt, ...) \ 56 do { \ 57 if (!(cond)) { \ 58 MEDIA_ERR_LOG(fmt, ##__VA_ARGS__); \ 59 return; \ 60 } \ 61 } while (0) 62 63 #define CHECK_AND_PRINT_LOG(cond, fmt, ...) \ 64 do { \ 65 if (!(cond)) { \ 66 MEDIA_ERR_LOG(fmt, ##__VA_ARGS__); \ 67 } \ 68 } while (0) 69 70 #define CHECK_AND_WARN_LOG(cond, fmt, ...) \ 71 do { \ 72 if (!(cond)) { \ 73 MEDIA_WARN_LOG(fmt, ##__VA_ARGS__); \ 74 } \ 75 } while (0) 76 77 #define CHECK_AND_RETURN_RET(cond, ret) \ 78 do { \ 79 if (!(cond)) { \ 80 return ret; \ 81 } \ 82 } while (0) 83 84 #endif // OHOS_MEDIA_LOG_H 85