• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 ACCESSTOKEN_COMMON_LOG_H
17 #define ACCESSTOKEN_COMMON_LOG_H
18 
19 #include "hilog/log.h"
20 
21 #define ATM_DOMAIN 0xD005A01
22 #define ATM_TAG "ATM"
23 
24 #define PRI_DOMAIN 0xD005A02
25 #define PRI_TAG "PRIVACY"
26 
27 #define LOGF(domain, tag, fmt, ...)            \
28     ((void)HILOG_IMPL(LOG_CORE, LOG_FATAL, domain, tag, \
29     "[%{upblic}s:%{public}d]" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__))
30 #define LOGE(domain, tag, fmt, ...)            \
31     ((void)HILOG_IMPL(LOG_CORE, LOG_ERROR, domain, tag, \
32     "[%{public}s:%{public}d]" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__))
33 #define LOGW(domain, tag, fmt, ...)            \
34     ((void)HILOG_IMPL(LOG_CORE, LOG_WARN, domain, tag, \
35     "[%{public}s:%{public}d]" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__))
36 #define LOGI(domain, tag, fmt, ...)            \
37     ((void)HILOG_IMPL(LOG_CORE, LOG_INFO, domain, tag, \
38     "[%{public}s:%{public}d]" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__))
39 #define LOGD(domain, tag, fmt, ...)            \
40     ((void)HILOG_IMPL(LOG_CORE, LOG_DEBUG, domain, tag, \
41     "[%{public}s:%{public}d]" fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__))
42 
43 #define IF_FALSE_PRINT_LOG(domain, tag, cond, fmt, ...) \
44     do { \
45         if (!(cond)) { \
46             LOGE(domain, tag, fmt, ##__VA_ARGS__); \
47         } \
48     } while (0)
49 
50 #define IF_FALSE_RETURN_LOG(domain, tag, cond, fmt, ...) \
51     do { \
52         if (!(cond)) { \
53             LOGE(domain, tag, fmt, ##__VA_ARGS__); \
54             return; \
55         } \
56     } while (0)
57 
58 #endif // ACCESSTOKEN_COMMON_LOG_H
59