• 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 HKS_LOG_H
17 #define HKS_LOG_H
18 
19 #include "hks_type.h"
20 
21 #ifdef HKS_CONFIG_FILE
22 #include HKS_CONFIG_FILE
23 #else
24 #include "hks_config.h"
25 #endif
26 
27 #ifdef _HUKS_LOG_ENABLE_
28 #ifdef HKS_ENABLE_LOG_PUBLIC
29 #define LOG_PUBLIC "{public}"
30 #else
31 #define LOG_PUBLIC
32 #endif
33 
34 #undef LOG_TAG
35 #define LOG_TAG "HUKS"
36 #undef LOG_DOMAIN
37 #define LOG_DOMAIN 0xD002F00 /* Security subsystem's domain id */
38 
39 #ifdef HKS_LOG_ENGINE_LOG_CORE
40 #include "hilog/log.h"
41 #define LOG_ENGINE LOG_CORE
42 #else
43 #ifdef HKS_LOG_ENGINE_HILOG_MODULE_SCY
44 #include "log.h"
45 #define LOG_ENGINE HILOG_MODULE_SCY
46 #endif
47 #endif
48 
49 #define HKS_LOG_I(fmt, arg...) HILOG_INFO(LOG_ENGINE, "%" LOG_PUBLIC "s[%" LOG_PUBLIC "u]: " fmt "\n", \
50                                                                                             __func__, __LINE__, ##arg)
51 #define HKS_LOG_W(fmt, arg...) HILOG_WARN(LOG_ENGINE, "%" LOG_PUBLIC "s[%" LOG_PUBLIC "u]: " fmt "\n", \
52                                                                                             __func__, __LINE__, ##arg)
53 #define HKS_LOG_E(fmt, arg...) HILOG_ERROR(LOG_ENGINE, "%" LOG_PUBLIC "s[%" LOG_PUBLIC "u]: " fmt "\n", \
54                                                                                             __func__, __LINE__, ##arg)
55 #define HKS_LOG_D(fmt, arg...) HILOG_DEBUG(LOG_ENGINE, "%" LOG_PUBLIC "s[%" LOG_PUBLIC "u]: " fmt "\n", \
56                                                                                             __func__, __LINE__, ##arg)
57 #else
58 #define HKS_LOG_I(...)
59 #define HKS_LOG_W(...)
60 #define HKS_LOG_E(...)
61 #define HKS_LOG_D(...)
62 #endif
63 
64 #endif /* HKS_LOG_H */
65