This page gives some information on how to trace the execution of Open NFC.
The debug facility — how trace messages are collected and displayed to the user — is part of the porting package: the CDebug* functions are provided by the user of Open NFC. For example, in the case of the Win32 porting, using the Connection Center, the traces are sent to a Trace Server via the Connection Center, or displayed on the console if the Trace Server is not available. In the case of the Android porting, the traces are collected in the adb facility and displayed with “adb logcat”. You should refer to your porting documentation in order to find out how the traces are handled.
While releases of Open NFC do trace only errors, the code is instrumented so that it is easy to add more verbosity to the code execution — beware, if you enable all the traces, there is a good chance the stack becomes so slow that it cannot function correctly anymore.
A good place for defining the trace level is the file porting_config.h. There are several levels of traces, for example P_TRACE_ERROR (trace only errors), P_TRACE_LOG (displays additional useful information), P_TRACE_TRACE (displays a lot of execution information). The trace level can be defined globally using P_TRACE_LEVEL_DEFAULT, and per-module using P_TRACE_LEVEL_[module name]. The module name can be found in the source files, as parameter of the P_MODULE_DEC() macro.
This example shows how to configure the stack to output some traces. It is based on the Win32 porting:
#define P_DEBUG_ACTIVE /* enables a few sanity checks in the stack */
#define P_TRACE_ACTIVE /* enables the trace facility in the stack and the porting */
#define P_TRACE_LEVEL_DEFAULT P_TRACE_ERROR /* log errors from any module */
#define P_TRACE_LEVEL_EMUL P_TRACE_TRACE /* log all information of card emul execution */
#define P_NFC_HAL_TRACE /* NAL traces, see porting guide */