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 namespace OHOS { 22 namespace { 23 // The "0xD001400" is the domain ID for graphic module that alloted by the OS. 24 #undef LOG_DOMAIN 25 #define LOG_DOMAIN 0xD001400 26 #undef LOG_TAG 27 #define LOG_TAG "Vsync" 28 } 29 30 #if (defined(__aarch64__) || defined(__x86_64__)) 31 #define VPUBI64 "%{public}ld" 32 #define VPUB_SIZE "%{public}lu" 33 #define VPUBU64 "%{public}lu" 34 #else 35 #define VPUBI64 "%{public}lld" 36 #define VPUB_SIZE "%{public}u" 37 #define VPUBU64 "%{public}llu" 38 #endif 39 40 #define VLOG_BASE(func, fmt, ...) \ 41 func(LOG_CORE, "%{public}s: " fmt, __func__, ##__VA_ARGS__) 42 43 #ifdef DEBUG 44 #define VLOGD(fmt, ...) VLOG_BASE(HILOG_DEBUG, fmt, ##__VA_ARGS__) 45 #else 46 #define VLOGD(fmt, ...) 47 #endif 48 #define VLOGI(fmt, ...) VLOG_BASE(HILOG_INFO, fmt, ##__VA_ARGS__) 49 #define VLOGW(fmt, ...) VLOG_BASE(HILOG_WARN, fmt, ##__VA_ARGS__) 50 #define VLOGE(fmt, ...) VLOG_BASE(HILOG_ERROR, fmt, ##__VA_ARGS__) 51 52 #define VLOG_SUCCESS(fmt, ...) VLOGI("Success, Way: " fmt, ##__VA_ARGS__) 53 #define VLOG_FAILURE(fmt, ...) VLOGE("Failure, Reason: " fmt, ##__VA_ARGS__) 54 #define VLOG_FAILURE_NO(vsync_error) VLOG_FAILURE("%{public}s", GSErrorStr(vsync_error).c_str()) 55 #define VLOG_FAILURE_RET(vsync_error) \ 56 do { \ 57 VLOG_FAILURE_NO(vsync_error); \ 58 return vsync_error; \ 59 } while (0) 60 #define VLOG_FAILURE_API(api, ret) VLOG_FAILURE(#api " failed with %{public}s", GSErrorStr(ret).c_str()) 61 62 #define VLOG_ERROR(errno, fmt, ...) \ 63 VLOGE(fmt ", means %{public}s", ##__VA_ARGS__, strerror(errno)) 64 65 #define VLOG_ERROR_API(ret, api) \ 66 VLOG_ERROR(ret, #api " failed with %{public}d", ret) 67 } // namespace OHOS 68 69 #endif // FRAMEWORKS_VSYNC_INCLUDE_VSYNC_LOG_H