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