• 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_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 "0xD001400" is the domain ID for graphic module that alloted by the OS.
24  constexpr ::OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0xD001401, "Bufferqueue" };
25  }
26  
27  #ifdef __aarch64__
28  #define BPUBI64  "%{public}ld"
29  #define BPUBSize "%{public}lu"
30  #define BPUBU64  "%{public}lu"
31  #else
32  #define BPUBI64  "%{public}lld"
33  #define BPUBSize "%{public}u"
34  #define BPUBU64  "%{public}llu"
35  #endif
36  
37  #define _B_DFUNC HiviewDFX::HiLog::Debug
38  #define _B_IFUNC HiviewDFX::HiLog::Info
39  #define _B_WFUNC HiviewDFX::HiLog::Warn
40  #define _B_EFUNC HiviewDFX::HiLog::Error
41  
42  #define _B_CNPRINTF(func, fmt, ...) \
43      func(LABEL, "(%{public}s) %{public}s: " fmt, \
44          name_.c_str(), __func__, ##__VA_ARGS__)
45  
46  #define _B_CPRINTF(func, fmt, ...) \
47      func(LABEL, "<%{public}d>%{public}s: " fmt, \
48          __LINE__, __func__, ##__VA_ARGS__)
49  
50  #define BLOGFD(fmt, ...) _B_CPRINTF(_B_DFUNC, "plz use self logfunc," fmt, ##__VA_ARGS__)
51  #define BLOGFI(fmt, ...) _B_CPRINTF(_B_IFUNC, "plz use self logfunc," fmt, ##__VA_ARGS__)
52  #define BLOGFW(fmt, ...) _B_CPRINTF(_B_WFUNC, "plz use self logfunc," fmt, ##__VA_ARGS__)
53  #define BLOGFE(fmt, ...) _B_CPRINTF(_B_EFUNC, "plz use self logfunc," fmt, ##__VA_ARGS__)
54  
55  #define BLOGD(fmt, ...) _B_CPRINTF(_B_DFUNC, fmt, ##__VA_ARGS__)
56  #define BLOGI(fmt, ...) _B_CPRINTF(_B_IFUNC, fmt, ##__VA_ARGS__)
57  #define BLOGW(fmt, ...) _B_CPRINTF(_B_WFUNC, fmt, ##__VA_ARGS__)
58  #define BLOGE(fmt, ...) _B_CPRINTF(_B_EFUNC, fmt, ##__VA_ARGS__)
59  
60  #define BLOGND(fmt, ...) _B_CNPRINTF(_B_DFUNC, fmt, ##__VA_ARGS__)
61  #define BLOGNI(fmt, ...) _B_CNPRINTF(_B_IFUNC, fmt, ##__VA_ARGS__)
62  #define BLOGNW(fmt, ...) _B_CNPRINTF(_B_WFUNC, fmt, ##__VA_ARGS__)
63  #define BLOGNE(fmt, ...) _B_CNPRINTF(_B_EFUNC, fmt, ##__VA_ARGS__)
64  
65  #define BLOGN_SUCCESS(fmt, ...) \
66      BLOGNI("Success, Way: " fmt, ##__VA_ARGS__)
67  
68  #define BLOGN_SUCCESS_ID(id, fmt, ...) \
69      BLOGNI("Success [%{public}d], Way: " fmt, id, ##__VA_ARGS__)
70  
71  #define BLOGN_INVALID(fmt, ...) \
72      BLOGNW("Invalid, " fmt, ##__VA_ARGS__)
73  
74  #define BLOGN_FAILURE(fmt, ...) \
75      BLOGNE("Failure, Reason: " fmt, ##__VA_ARGS__)
76  
77  #define BLOGN_FAILURE_RET(ret)                                     \
78      do {                                                          \
79          BLOGN_FAILURE("%{public}s", GSErrorStr(ret).c_str()); \
80          return ret;                                               \
81      } while (0)
82  
83  #define BLOGN_FAILURE_API(api, ret) \
84      BLOGN_FAILURE(#api " failed, then %{public}s", GSErrorStr(ret).c_str())
85  
86  #define BLOGN_FAILURE_ID(id, fmt, ...) \
87      BLOGNE("Failure [%{public}d], Reason: " fmt, id, ##__VA_ARGS__)
88  
89  #define BLOGN_FAILURE_ID_RET(id, ret)                                     \
90      do {                                                                 \
91          BLOGN_FAILURE_ID(id, "%{public}s", GSErrorStr(ret).c_str()); \
92          return ret;                                                      \
93      } while (0)
94  
95  #define BLOGN_FAILURE_ID_API(id, api, ret) \
96      BLOGN_FAILURE_ID(id, #api " failed, then %{public}s", GSErrorStr(ret).c_str())
97  } // namespace OHOS
98  
99  #endif // FRAMEWORKS_SURFACE_INCLUDE_BUFFER_LOG_H
100