• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the openHiTLS project.
3  *
4  * openHiTLS is licensed under the Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *
8  *     http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  * See the Mulan PSL v2 for more details.
14  */
15 
16 #ifndef BSL_LOG_INTERNAL_H
17 #define BSL_LOG_INTERNAL_H
18 
19 #include <stdint.h>
20 #include "hitls_build.h"
21 #include "bsl_log.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #ifdef HITLS_BSL_LOG
28 #ifdef HITLS_BSL_LOG_NO_FORMAT_STRING
29 #define LOG_STR(str) NULL
30 #else
31 #define LOG_STR(str) (str)
32 #endif
33 
34 #define BSL_LOG_BUF_SIZE            1024U
35 
36 /**
37  * @ingroup bsl_log
38  * @brief four-parameter dotting log function
39  * @attention A maximum of four parameters can be contained in the formatted string.
40  *            If the number of parameters is less than four, 0s or NULL must be added.
41  *            If the number of parameters exceeds four, multiple invoking is required.
42  *            Only the LOG_BINLOG_FIXLEN macro can be invoked. This macro cannot be redefined.
43  * @param logId [IN] Log ID
44  * @param logLevel [IN] Log level
45  * @param logType [IN] String label
46  * @param format [IN] Format string. Only literal strings are allowed. Variables are not allowed.
47  * @param para1 [IN] Parameter 1
48  * @param para2 [IN] Parameter 2
49  * @param para3 [IN] Parameter 3
50  * @param para4 [IN] Parameter 4
51  */
52 void BSL_LOG_BinLogFixLen(uint32_t logId, uint32_t logLevel, uint32_t logType,
53     void *format, void *para1, void *para2, void *para3, void *para4);
54 
55 /**
56  * @ingroup bsl_log
57  * @brief one-parameter dotting log function
58  * @attention The formatted character string contains only one parameter, which is %s.
59  *            For a pure character string, use LOG_BinLogFixLen
60  *            Only the LOG_BINLOG_VARLEN macro can be invoked. This macro cannot be redefined.
61  * @param logId [IN] Log ID
62  * @param logLevel [IN] Log level
63  * @param logType [IN] String label
64  * @param format [IN] Format string. Only literal strings are allowed. Variables are not allowed.
65  * @param para [IN] Parameter
66  */
67 void BSL_LOG_BinLogVarLen(uint32_t logId, uint32_t logLevel, uint32_t logType, void *format, void *para);
68 
69 /**
70  * @ingroup bsl_log
71  * @brief four-parameter dotting log macro
72  * @attention A maximum of four parameters can be contained in the formatted string.
73  *            If the number of parameters is less than four, 0s or NULL must be added.
74  *            If the number of parameters exceeds four, multiple invoking is required.
75  * @param logId [IN] Log ID
76  * @param logLevel [IN] Log level
77  * @param logType [IN] String label
78  * @param format [IN] Format string. Only literal strings are allowed. Variables are not allowed.
79  * @param para1 [IN] Parameter 1
80  * @param para2 [IN] Parameter 2
81  * @param para3 [IN] Parameter 3
82  * @param para4 [IN] Parameter 4
83  */
84 #define BSL_LOG_BINLOG_FIXLEN(logId, logLevel, logType, format, para1, para2, para3, para4) \
85     BSL_LOG_BinLogFixLen(logId, logLevel, logType, \
86         (void *)(uintptr_t)(const void *)(LOG_STR(format)), (void *)(uintptr_t)(para1), (void *)(uintptr_t)(para2), \
87         (void *)(uintptr_t)(para3), (void *)(uintptr_t)(para4))
88 
89 /**
90  * @ingroup bsl_log
91  * @brief one-parameter dotting log macro
92  * @attention The formatted character string contains only one parameter, which is %s.
93  *            For a pure character string, use LOG_BinLogFixLen
94  * @param logId [IN] Log ID
95  * @param logLevel [IN] Log level
96  * @param logType [IN] String label
97  * @param format [IN] Format string. Only literal strings are allowed. Variables are not allowed.
98  * @param para [IN] Parameter
99  */
100 #define BSL_LOG_BINLOG_VARLEN(logId, logLevel, logType, format, para) \
101     BSL_LOG_BinLogVarLen(logId, logLevel, logType, \
102         (void *)(uintptr_t)(const void *)(LOG_STR(format)), (void *)(uintptr_t)(const void *)(para))
103 
104 #else
105 
106 #define BSL_LOG_BINLOG_FIXLEN(logId, logLevel, logType, format, para1, para2, para3, para4)
107 #define BSL_LOG_BINLOG_VARLEN(logId, logLevel, logType, format, para)
108 
109 #endif /* HITLS_BSL_LOG */
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif // BSL_LOG_INTERNAL_H
116