1 /* 2 * Copyright (C) 2023-2023 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 * Description: Log format definitions. 15 * Author: zhangge 16 * Create: 2022-06-15 17 */ 18 19 #ifndef CAST_ENGINE_LOG_H 20 #define CAST_ENGINE_LOG_H 21 22 #include "hilog/log_cpp.h" 23 24 using OHOS::HiviewDFX::HiLog; 25 using OHOS::HiviewDFX::HiLogLabel; 26 27 namespace OHOS { 28 namespace CastEngine { 29 inline constexpr unsigned int CASTPLUS_LOG_BEGIN = 0xD004600; 30 inline constexpr unsigned int CAST_ENGINE_LOG_ID = CASTPLUS_LOG_BEGIN + 0x01; 31 inline constexpr unsigned int CASTPLUS_LOG_END = CASTPLUS_LOG_BEGIN + 0x10; 32 33 inline constexpr bool DEBUG = true; 34 35 #define DEFINE_CAST_ENGINE_LABEL(name) \ 36 static constexpr HiLogLabel CAST_ENGINE_LABEL = { LOG_CORE, OHOS::CastEngine::CAST_ENGINE_LOG_ID, name } 37 38 #define CLOGV(format, ...) \ 39 do { \ 40 if (DEBUG) { \ 41 (void)HiLog::Error(CAST_ENGINE_LABEL, "[%{public}s:%{public}d]: " format, __func__, __LINE__, \ 42 ##__VA_ARGS__); \ 43 } \ 44 } while (0) 45 #define CLOGD(format, ...) \ 46 (void)HiLog::Error(CAST_ENGINE_LABEL, "[%{public}s:%{public}d]: " format, __func__, __LINE__, ##__VA_ARGS__) 47 #define CLOGI(format, ...) \ 48 (void)HiLog::Error(CAST_ENGINE_LABEL, "[%{public}s:%{public}d]: " format, __func__, __LINE__, ##__VA_ARGS__) 49 #define CLOGW(format, ...) \ 50 (void)HiLog::Error(CAST_ENGINE_LABEL, "[%{public}s:%{public}d]: " format, __func__, __LINE__, ##__VA_ARGS__) 51 #define CLOGE(format, ...) \ 52 (void)HiLog::Error(CAST_ENGINE_LABEL, "[%{public}s:%{public}d]: " format, __func__, __LINE__, ##__VA_ARGS__) 53 54 #define CHECK_AND_RETURN_RET_LOG(cond, ret, fmt, ...) \ 55 do { \ 56 if (cond) { \ 57 CLOGE(fmt, ##__VA_ARGS__); \ 58 return ret; \ 59 } \ 60 } while (0) 61 } // namespace CastEngine 62 } // namespace OHOS 63 64 #endif