nRF51 SDK - S120 SoftDevice
|
The logger module provides simple log messages over UART for debugging purposes. In case debug messages are to be enabled, ENABLE_DEBUG_LOG_SUPPORT should be defined in the project. Logging can be easily disabled by removing the define ENABLE_DEBUG_LOG_SUPPORT from the project.
The module must be initialized before logging can be be done using the module API app_trace_init. Initialization routine takes care of initializing and configuring UART. UART configuration used by logger module in SDK uses a baud rate of 38400 bps, with no flow control or parity.
The application should use app_trace_log API to print trace messages over UART. Please note that the string being printed should end with \r\n for neat formatting on the terminal.
The logger module is used by the Connection Manager and application in SDK examples. It should be noted that these modules do not use the logger module directly through out the code. But a macro is used to enable logging. For example, connection manager defines a macro called the CONN_MNGR_LOG which is defined to app_trace_log. The advantage of this is to be able enable or disable selectively log messages from a certain module in case too many modules are logging messages and debugging gets convoluted.
Further, practice of including a module signature is added in order to map each message with a particular module. For example, all messages from connection manager start with "[CM]:" followed by the message.