• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FRAMEWORKS_VSYNC_INCLUDE_VSYNC_LOG_H
17 #define FRAMEWORKS_VSYNC_INCLUDE_VSYNC_LOG_H
18 
19 #include <hilog/log.h>
20 
21 #ifdef __aarch64__
22 #define VPUBI64  "%{public}ld"
23 #define VPUBSize "%{public}lu"
24 #define VPUBU64  "%{public}lu"
25 #else
26 #define VPUBI64  "%{public}lld"
27 #define VPUBSize "%{public}u"
28 #define VPUBU64  "%{public}llu"
29 #endif
30 
31 #define VLOG_BASE(func, fmt, ...) \
32     func(LABEL, "%{public}s: " fmt, __func__, ##__VA_ARGS__)
33 
34 #define VLOGD(fmt, ...) VLOG_BASE(::OHOS::HiviewDFX::HiLog::Debug, fmt, ##__VA_ARGS__)
35 #define VLOGI(fmt, ...) VLOG_BASE(::OHOS::HiviewDFX::HiLog::Info, fmt, ##__VA_ARGS__)
36 #define VLOGW(fmt, ...) VLOG_BASE(::OHOS::HiviewDFX::HiLog::Warn, fmt, ##__VA_ARGS__)
37 #define VLOGE(fmt, ...) VLOG_BASE(::OHOS::HiviewDFX::HiLog::Error, fmt, ##__VA_ARGS__)
38 
39 #define VLOG_SUCCESS(fmt, ...) VLOGI("Success, Way: " fmt, ##__VA_ARGS__)
40 #define VLOG_FAILURE(fmt, ...) VLOGE("Failure, Reason: " fmt, ##__VA_ARGS__)
41 #define VLOG_FAILURE_NO(vsync_error) VLOG_FAILURE("%{public}s", GSErrorStr(vsync_error).c_str())
42 #define VLOG_FAILURE_RET(vsync_error) \
43     do {                              \
44         VLOG_FAILURE_NO(vsync_error); \
45         return vsync_error;           \
46     } while (0)
47 #define VLOG_FAILURE_API(api, ret) VLOG_FAILURE(#api " failed with %{public}s", GSErrorStr(ret).c_str())
48 
49 #define VLOG_ERROR(errno, fmt, ...) \
50     VLOGE(fmt ", means %{public}s", ##__VA_ARGS__, strerror(errno))
51 
52 #define VLOG_ERROR_API(ret, api) \
53     VLOG_ERROR(ret, #api " failed with %{public}d", ret)
54 
55 #endif // FRAMEWORKS_VSYNC_INCLUDE_VSYNC_LOG_H
56