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 #ifndef UPDATE_DEFINE_H 16 #define UPDATE_DEFINE_H 17 18 #include "hilog/log.h" 19 20 namespace OHOS { 21 namespace UpdateEngine { 22 static constexpr OHOS::HiviewDFX::HiLogLabel UPDATE_CLIENT = {LOG_CORE, 0XD002E00, "UPDATE_CLIENT"}; 23 24 #define CLIENT_LOGI(format, ...) \ 25 OHOS::HiviewDFX::HiLog::Info(UPDATE_CLIENT, "[%{public}s(%{public}d)] " format, \ 26 UpdateHelper::GetBriefFileName(std::string(__FILE__)).c_str(), __LINE__, ##__VA_ARGS__) 27 28 #define CLIENT_LOGE(format, ...) \ 29 OHOS::HiviewDFX::HiLog::Error(UPDATE_CLIENT, "[%{public}s(%{public}d)] " format, \ 30 UpdateHelper::GetBriefFileName(std::string(__FILE__)).c_str(), __LINE__, ##__VA_ARGS__) 31 32 #define PARAM_CHECK(validCheck, exper, ...) \ 33 if (!(validCheck)) { \ 34 CLIENT_LOGE(__VA_ARGS__); \ 35 exper; \ 36 } 37 38 #define PARAM_CHECK_NAPI_CALL(env, assertion, exper, message) \ 39 if (!(assertion)) { \ 40 CLIENT_LOGE(message); \ 41 exper; \ 42 } 43 44 #define COUNT_OF(array) (sizeof(array) / sizeof((array)[0])) 45 46 #define INDEX(x) ((x) - 1) 47 } // namespace UpdateEngine 48 } // namespace OHOS 49 #endif // UPDATE_DEFINE_H