• 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 HDI_BACKEND_HDI_LOG_H
17 #define HDI_BACKEND_HDI_LOG_H
18 
19 #include <hilog/log.h>
20 
21 #include "graphic_error.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 
26 namespace {
27 // The "0xD001400" is the domain ID for graphic module that alloted by the OS.
28 constexpr ::OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, 0xD001400, "Composer" };
29 }
30 
31 #define __HLOG(func, fmt, ...) \
32     func(LABEL, "%{public}s: " fmt , __func__, ##__VA_ARGS__)
33 
34 #define HLOGD(fmt, ...) __HLOG(::OHOS::HiviewDFX::HiLog::Debug, fmt, ##__VA_ARGS__)
35 #define HLOGI(fmt, ...) __HLOG(::OHOS::HiviewDFX::HiLog::Info, fmt, ##__VA_ARGS__)
36 #define HLOGW(fmt, ...) __HLOG(::OHOS::HiviewDFX::HiLog::Warn, fmt, ##__VA_ARGS__)
37 #define HLOGE(fmt, ...) __HLOG(::OHOS::HiviewDFX::HiLog::Error, fmt, ##__VA_ARGS__)
38 
39 #define HLOG_SUCCESS(fmt, ...) HLOGI("Success, Way: " fmt, ##__VA_ARGS__)
40 #define HLOG_FAILURE(fmt, ...) HLOGE("Failure, Reason: " fmt, ##__VA_ARGS__)
41 
42 #define HLOG_ERROR(errno, fmt, ...) \
43     HLOGE(fmt ", means %{public}s", ##__VA_ARGS__, strerror(errno))
44 
45 #define HLOG_ERROR_API(ret, api) \
46     HLOG_ERROR(ret, #api " failed with %{public}d", ret)
47 
48 } // namespace Rosen
49 } // namespace OHOS
50 
51 #endif // HDI_BACKEND_HDI_LOG_H