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