1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
/*
* Copyright (C) 2010-2014 NXP Semiconductors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if !defined(NXPLOG__H_INCLUDED)
#define NXPLOG__H_INCLUDED
#include <log/log.h>
typedef struct nci_log_level {
uint8_t global_log_level;
uint8_t extns_log_level;
uint8_t hal_log_level;
uint8_t dnld_log_level;
uint8_t tml_log_level;
uint8_t ncix_log_level;
uint8_t ncir_log_level;
} nci_log_level_t;
/* global log level Ref */
extern nci_log_level_t gLog_level;
/* define log module included when compile */
#define ENABLE_EXTNS_TRACES TRUE
#define ENABLE_HAL_TRACES TRUE
#define ENABLE_TML_TRACES TRUE
#define ENABLE_FWDNLD_TRACES TRUE
#define ENABLE_NCIX_TRACES TRUE
#define ENABLE_NCIR_TRACES TRUE
#define ENABLE_HCPX_TRACES FALSE
#define ENABLE_HCPR_TRACES FALSE
/* ####################### Set the log module name in .conf file
* ########################## */
#define NAME_NXPLOG_EXTNS_LOGLEVEL "NXPLOG_EXTNS_LOGLEVEL"
#define NAME_NXPLOG_HAL_LOGLEVEL "NXPLOG_NCIHAL_LOGLEVEL"
#define NAME_NXPLOG_NCIX_LOGLEVEL "NXPLOG_NCIX_LOGLEVEL"
#define NAME_NXPLOG_NCIR_LOGLEVEL "NXPLOG_NCIR_LOGLEVEL"
#define NAME_NXPLOG_FWDNLD_LOGLEVEL "NXPLOG_FWDNLD_LOGLEVEL"
#define NAME_NXPLOG_TML_LOGLEVEL "NXPLOG_TML_LOGLEVEL"
/* ####################### Set the log module name by Android property
* ########################## */
#define PROP_NAME_NXPLOG_GLOBAL_LOGLEVEL "nfc.nxp_log_level_global"
#define PROP_NAME_NXPLOG_EXTNS_LOGLEVEL "nfc.nxp_log_level_extns"
#define PROP_NAME_NXPLOG_HAL_LOGLEVEL "nfc.nxp_log_level_hal"
#define PROP_NAME_NXPLOG_NCI_LOGLEVEL "nfc.nxp_log_level_nci"
#define PROP_NAME_NXPLOG_FWDNLD_LOGLEVEL "nfc.nxp_log_level_dnld"
#define PROP_NAME_NXPLOG_TML_LOGLEVEL "nfc.nxp_log_level_tml"
/* ####################### Set the logging level for EVERY COMPONENT here
* ######################## :START: */
#define NXPLOG_LOG_SILENT_LOGLEVEL 0x00
#define NXPLOG_LOG_ERROR_LOGLEVEL 0x01
#define NXPLOG_LOG_WARN_LOGLEVEL 0x02
#define NXPLOG_LOG_DEBUG_LOGLEVEL 0x03
/* ####################### Set the default logging level for EVERY COMPONENT
* here ########################## :END: */
/* The Default log level for all the modules. */
#define NXPLOG_DEFAULT_LOGLEVEL NXPLOG_LOG_ERROR_LOGLEVEL
/* ################################################################################################################
*/
/* ############################################### Component Names
* ################################################ */
/* ################################################################################################################
*/
extern const char* NXPLOG_ITEM_EXTNS; /* Android logging tag for NxpExtns */
extern const char* NXPLOG_ITEM_NCIHAL; /* Android logging tag for NxpNciHal */
extern const char* NXPLOG_ITEM_NCIX; /* Android logging tag for NxpNciX */
extern const char* NXPLOG_ITEM_NCIR; /* Android logging tag for NxpNciR */
extern const char* NXPLOG_ITEM_FWDNLD; /* Android logging tag for NxpFwDnld */
extern const char* NXPLOG_ITEM_TML; /* Android logging tag for NxpTml */
#ifdef NXP_HCI_REQ
extern const char* NXPLOG_ITEM_HCPX; /* Android logging tag for NxpHcpX */
extern const char* NXPLOG_ITEM_HCPR; /* Android logging tag for NxpHcpR */
#endif /*NXP_HCI_REQ*/
/* ######################################## Defines used for Logging data
* ######################################### */
#ifdef NXP_VRBS_REQ
#define NXPLOG_FUNC_ENTRY(COMP) \
LOG_PRI(ANDROID_LOG_VERBOSE, (COMP), "+:%s", (__func__))
#define NXPLOG_FUNC_EXIT(COMP) \
LOG_PRI(ANDROID_LOG_VERBOSE, (COMP), "-:%s", (__func__))
#endif /*NXP_VRBS_REQ*/
/* ################################################################################################################
*/
/* ######################################## Logging APIs of actual modules
* ######################################## */
/* ################################################################################################################
*/
/* Logging APIs used by NxpExtns module */
#if (ENABLE_EXTNS_TRACES == TRUE)
#define NXPLOG_EXTNS_D(...) \
{ \
if (gLog_level.extns_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \
}
#define NXPLOG_EXTNS_W(...) \
{ \
if (gLog_level.extns_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \
}
#define NXPLOG_EXTNS_E(...) \
{ \
if (gLog_level.extns_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_EXTNS, __VA_ARGS__); \
}
#else
#define NXPLOG_EXTNS_D(...)
#define NXPLOG_EXTNS_W(...)
#define NXPLOG_EXTNS_E(...)
#endif /* Logging APIs used by NxpExtns module */
/* Logging APIs used by NxpNciHal module */
#if (ENABLE_HAL_TRACES == TRUE)
#define NXPLOG_NCIHAL_D(...) \
{ \
if (gLog_level.hal_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_NCIHAL, __VA_ARGS__); \
}
#define NXPLOG_NCIHAL_W(...) \
{ \
if (gLog_level.hal_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_NCIHAL, __VA_ARGS__); \
}
#define NXPLOG_NCIHAL_E(...) \
{ \
if (gLog_level.hal_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_NCIHAL, __VA_ARGS__); \
}
#else
#define NXPLOG_NCIHAL_D(...)
#define NXPLOG_NCIHAL_W(...)
#define NXPLOG_NCIHAL_E(...)
#endif /* Logging APIs used by HAL module */
/* Logging APIs used by NxpNciX module */
#if (ENABLE_NCIX_TRACES == TRUE)
#define NXPLOG_NCIX_D(...) \
{ \
if (gLog_level.ncix_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_NCIX, __VA_ARGS__); \
}
#define NXPLOG_NCIX_W(...) \
{ \
if (gLog_level.ncix_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_NCIX, __VA_ARGS__); \
}
#define NXPLOG_NCIX_E(...) \
{ \
if (gLog_level.ncix_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_NCIX, __VA_ARGS__); \
}
#else
#define NXPLOG_NCIX_D(...)
#define NXPLOG_NCIX_W(...)
#define NXPLOG_NCIX_E(...)
#endif /* Logging APIs used by NCIx module */
/* Logging APIs used by NxpNciR module */
#if (ENABLE_NCIR_TRACES == TRUE)
#define NXPLOG_NCIR_D(...) \
{ \
if (gLog_level.ncir_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_NCIR, __VA_ARGS__); \
}
#define NXPLOG_NCIR_W(...) \
{ \
if (gLog_level.ncir_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_NCIR, __VA_ARGS__); \
}
#define NXPLOG_NCIR_E(...) \
{ \
if (gLog_level.ncir_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_NCIR, __VA_ARGS__); \
}
#else
#define NXPLOG_NCIR_D(...)
#define NXPLOG_NCIR_W(...)
#define NXPLOG_NCIR_E(...)
#endif /* Logging APIs used by NCIR module */
/* Logging APIs used by NxpFwDnld module */
#if (ENABLE_FWDNLD_TRACES == TRUE)
#define NXPLOG_FWDNLD_D(...) \
{ \
if (gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
}
#define NXPLOG_FWDNLD_W(...) \
{ \
if (gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
}
#define NXPLOG_FWDNLD_E(...) \
{ \
if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
}
#else
#define NXPLOG_FWDNLD_D(...)
#define NXPLOG_FWDNLD_W(...)
#define NXPLOG_FWDNLD_E(...)
#endif /* Logging APIs used by NxpFwDnld module */
/* Logging APIs used by NxpTml module */
#if (ENABLE_TML_TRACES == TRUE)
#define NXPLOG_TML_D(...) \
{ \
if (gLog_level.tml_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_TML, __VA_ARGS__); \
}
#define NXPLOG_TML_W(...) \
{ \
if (gLog_level.tml_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_TML, __VA_ARGS__); \
}
#define NXPLOG_TML_E(...) \
{ \
if (gLog_level.tml_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_TML, __VA_ARGS__); \
}
#else
#define NXPLOG_TML_D(...)
#define NXPLOG_TML_W(...)
#define NXPLOG_TML_E(...)
#endif /* Logging APIs used by NxpTml module */
#ifdef NXP_HCI_REQ
/* Logging APIs used by NxpHcpX module */
#if (ENABLE_HCPX_TRACES == TRUE)
#define NXPLOG_HCPX_D(...) \
{ \
if (gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
}
#define NXPLOG_HCPX_W(...) \
{ \
if (gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
}
#define NXPLOG_HCPX_E(...) \
{ \
if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
}
#else
#define NXPLOG_HCPX_D(...)
#define NXPLOG_HCPX_W(...)
#define NXPLOG_HCPX_E(...)
#endif /* Logging APIs used by NxpHcpX module */
/* Logging APIs used by NxpHcpR module */
#if (ENABLE_HCPR_TRACES == TRUE)
#define NXPLOG_HCPR_D(...) \
{ \
if (gLog_level.dnld_log_level >= NXPLOG_LOG_DEBUG_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_DEBUG, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
}
#define NXPLOG_HCPR_W(...) \
{ \
if (gLog_level.dnld_log_level >= NXPLOG_LOG_WARN_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_WARN, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
}
#define NXPLOG_HCPR_E(...) \
{ \
if (gLog_level.dnld_log_level >= NXPLOG_LOG_ERROR_LOGLEVEL) \
LOG_PRI(ANDROID_LOG_ERROR, NXPLOG_ITEM_FWDNLD, __VA_ARGS__); \
}
#else
#define NXPLOG_HCPR_D(...)
#define NXPLOG_HCPR_W(...)
#define NXPLOG_HCPR_E(...)
#endif /* Logging APIs used by NxpHcpR module */
#endif /* NXP_HCI_REQ */
#ifdef NXP_VRBS_REQ
#if (ENABLE_EXTNS_TRACES == TRUE)
#define NXPLOG_EXTNS_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_EXTNS)
#define NXPLOG_EXTNS_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_EXTNS)
#else
#define NXPLOG_EXTNS_ENTRY()
#define NXPLOG_EXTNS_EXIT()
#endif
#if (ENABLE_HAL_TRACES == TRUE)
#define NXPLOG_NCIHAL_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIHAL)
#define NXPLOG_NCIHAL_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIHAL)
#else
#define NXPLOG_NCIHAL_ENTRY()
#define NXPLOG_NCIHAL_EXIT()
#endif
#if (ENABLE_NCIX_TRACES == TRUE)
#define NXPLOG_NCIX_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIX)
#define NXPLOG_NCIX_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIX)
#else
#define NXPLOG_NCIX_ENTRY()
#define NXPLOG_NCIX_EXIT()
#endif
#if (ENABLE_NCIR_TRACES == TRUE)
#define NXPLOG_NCIR_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_NCIR)
#define NXPLOG_NCIR_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_NCIR)
#else
#define NXPLOG_NCIR_ENTRY()
#define NXPLOG_NCIR_EXIT()
#endif
#ifdef NXP_HCI_REQ
#if (ENABLE_HCPX_TRACES == TRUE)
#define NXPLOG_HCPX_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_HCPX)
#define NXPLOG_HCPX_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_HCPX)
#else
#define NXPLOG_HCPX_ENTRY()
#define NXPLOG_HCPX_EXIT()
#endif
#if (ENABLE_HCPR_TRACES == TRUE)
#define NXPLOG_HCPR_ENTRY() NXPLOG_FUNC_ENTRY(NXPLOG_ITEM_HCPR)
#define NXPLOG_HCPR_EXIT() NXPLOG_FUNC_EXIT(NXPLOG_ITEM_HCPR)
#else
#define NXPLOG_HCPR_ENTRY()
#define NXPLOG_HCPR_EXIT()
#endif
#endif /* NXP_HCI_REQ */
#endif /* NXP_VRBS_REQ */
void phNxpLog_InitializeLogLevel(void);
#endif /* NXPLOG__H_INCLUDED */
|