Debugging

External Resources

Enabling Logging from the Azure Libraries

Linking the Debug Libraries

The Plugin for Azure IoT provides two versions of the Azure PAL and SDK libraries, release and debug. The release library is prebuilt with the NO_LOGGING flag defined and therefore provides no logging capabilities. The debug library does not define this flag and therefore has logging capabilities enabled. To enable logging, start by linking against the debug version of the library. In your linked libraries modify:

<AZURE_INSTALL_DIR>/source/third_party/azure-iot-pal-simplelink/build_all/pal/lib/<toolchain>/m4(f)/pal_sl_release.a

To:

<AZURE_INSTALL_DIR>/source/third_party/azure-iot-pal-simplelink/build_all/pal/lib/<toolchain>/m4(f)/pal_sl_debug.a

And similarly do the same change from release to debug for any other linked libraries in:

<AZURE_INSTALL_DIR>/source/third_party/azure-iot-pal-simplelink/build_all/sdk/lib/<toolchain>/m4(f)/

Enabling Logging in the Application

The examples provided with the Plugin for Azure IoT provide the code needed to enable logging in the application. This code is wrapped in a conditional that is enabled if the ENABLE_LOGGING flag is defined. Therefore in order to enable this change the following line in the example:

// #define ENABLE_LOGGING

to:

#define ENABLE_LOGGING

Runtime logging enable/disable

Some protocols such as MQTT require that logging be enabled at runtime by setting a protocol specific option. Some examples already contain the following code used to enable it. If the code is not present, add the following:

bool traceOn = true;
IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_LOG_TRACE, &traceOn);