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_SURFACE_INCLUDE_BUFFER_LOG_H 17 #define FRAMEWORKS_SURFACE_INCLUDE_BUFFER_LOG_H 18 19 #include <hilog/log.h> 20 21 namespace OHOS { 22 namespace { 23 // The "0xD001401" is the domain ID for graphic module that alloted by the OS. 24 #undef LOG_DOMAIN 25 #define LOG_DOMAIN 0xD001401 26 #undef LOG_TAG 27 #define LOG_TAG "Bufferqueue" 28 } 29 30 #if (defined(__aarch64__) || defined(__x86_64__)) 31 #define BPUBI64 "%{public}ld" 32 #define BPUB_SIZE "%{public}lu" 33 #define BPUBU64 "%{public}lu" 34 #else 35 #define BPUBI64 "%{public}lld" 36 #define BPUB_SIZE "%{public}u" 37 #define BPUBU64 "%{public}llu" 38 #endif 39 40 #define B_CPRINTF(func, fmt, ...) \ 41 func(LOG_CORE, "<%{public}s:%{public}d-%{public}s>: " fmt, \ 42 __FILE_NAME__, __LINE__, __func__, ##__VA_ARGS__) 43 44 #define BLOGD(fmt, ...) B_CPRINTF(HILOG_DEBUG, fmt, ##__VA_ARGS__) 45 #define BLOGI(fmt, ...) B_CPRINTF(HILOG_INFO, fmt, ##__VA_ARGS__) 46 #define BLOGW(fmt, ...) B_CPRINTF(HILOG_WARN, fmt, ##__VA_ARGS__) 47 #define BLOGE(fmt, ...) B_CPRINTF(HILOG_ERROR, fmt, ##__VA_ARGS__) 48 49 #define BLOGN_FAILURE_RET(ret) \ 50 do { \ 51 BLOGE("Fail ret: %{public}d, uniqueId: %{public}" PRIu64 ".", ret, uniqueId_); \ 52 return ret; \ 53 } while (0) 54 55 #define BLOGE_CHECK_AND_RETURN_RET(cond, ret, fmt, ...) \ 56 do { \ 57 if (!(cond)) { \ 58 BLOGE(fmt, ##__VA_ARGS__); \ 59 return ret; \ 60 } \ 61 } while (0) 62 } // namespace OHOS 63 64 #endif // FRAMEWORKS_SURFACE_INCLUDE_BUFFER_LOG_H 65