1 /* 2 * Copyright (C) 2022 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 OHOS_MEDIALIBRARY_COMMON_LOG_H 17 #define OHOS_MEDIALIBRARY_COMMON_LOG_H 18 19 #include "hilog/log.h" 20 21 #ifndef C_MLOG_TAG 22 #define C_MLOG_TAG "Common" 23 #endif 24 25 #undef C_LOG_DOMAIN 26 #define C_LOG_DOMAIN 0xD002B70 27 28 #undef C_LOG_TAG 29 #define C_LOG_TAG "MediaLibraryCommon" 30 31 #ifndef C_LOG_LABEL 32 #define C_LOG_LABEL { LOG_CORE, C_LOG_DOMAIN, C_LOG_TAG } 33 #endif 34 35 #define COMMON_HILOG(op, fmt, args...) \ 36 do { \ 37 op(C_LOG_LABEL, C_MLOG_TAG ":{%{public}s:%{public}d} " fmt, __FUNCTION__, __LINE__, ##args); \ 38 } while (0) 39 40 #define COMMON_DEBUG_LOG(fmt, ...) COMMON_HILOG(OHOS::HiviewDFX::HiLog::Debug, fmt, ##__VA_ARGS__) 41 #define COMMON_ERR_LOG(fmt, ...) COMMON_HILOG(OHOS::HiviewDFX::HiLog::Error, fmt, ##__VA_ARGS__) 42 #define COMMON_WARN_LOG(fmt, ...) COMMON_HILOG(OHOS::HiviewDFX::HiLog::Warn, fmt, ##__VA_ARGS__) 43 #define COMMON_INFO_LOG(fmt, ...) COMMON_HILOG(OHOS::HiviewDFX::HiLog::Info, fmt, ##__VA_ARGS__) 44 #define COMMON_FATAL_LOG(fmt, ...) COMMON_HILOG(OHOS::HiviewDFX::HiLog::Fatal, fmt, ##__VA_ARGS__) 45 46 #define CHECK_AND_ERR_LOG(cond, fmt, ...) \ 47 do { \ 48 if (!(cond)) { \ 49 COMMON_ERR_LOG(fmt, ##__VA_ARGS__); \ 50 } \ 51 } while (0) 52 53 #endif // OHOS_MEDIALIBRARY_COMMON_LOG_H 54