This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unable to use NRF_LOG_DEBUG with CLI example

Baseline: CLI example on the 52832 with SDK v15.3

I assume the issue will be some more undocumented fix.

sdk_config.h

// <o> NRF_LOG_DEFAULT_LEVEL  - Default Severity level
 
// <0=> Off 
// <1=> Error 
// <2=> Warning 
// <3=> Info 
// <4=> Debug 

#ifndef NRF_LOG_DEFAULT_LEVEL
#define NRF_LOG_DEFAULT_LEVEL 4
#endif

main.c from the CLI example (UART backend)

NRF_LOG_INFO("This is an INFO Message");
NRF_LOG_DEBUG("This is a DEBUG Message");
NRF_LOG_WARNING("This is a WARNING Message");
NRF_LOG_ERROR("This is a ERROR Message");

Output of the program (If that is too small, the Debug statement is not printed.)

You cannot add a DEBUG color (NRF_LOG_DEBUG_COLOR) because it breaks the build due to redefinition.  However, I do not think that is the problem. 

It is tedious to go through the log code because the code is generated on the fly by 10 deep macros where symbol names are made by ## context.

Anybody have an idea what I am missing.

Thanks,

Jim

  • As far as I know, there are no configs for setting the log level specific for the app, it will use the NRF_LOG_DEFAULT_LEVEL config and use the module name "app". There is nothing stopping you from creating your own configs for the app, and change the name of the module, similar to how this is done in other modules:

    #define MAIN_CONFIG_LOG_ENABLED 1
    #define MAIN_CONFIG_LOG_LEVEL 4
    #define MAIN_CONFIG_INFO_COLOR 2
    #define MAIN_CONFIG_DEBUG_COLOR 3
    
    #define NRF_LOG_MODULE_NAME main_cli
    #if MAIN_CONFIG_LOG_ENABLED
    #define NRF_LOG_LEVEL       MAIN_CONFIG_LOG_LEVEL
    #define NRF_LOG_INFO_COLOR  MAIN_CONFIG_INFO_COLOR
    #define NRF_LOG_DEBUG_COLOR MAIN_CONFIG_DEBUG_COLOR
    #else //MAIN_CONFIG_LOG_ENABLED
    #define NRF_LOG_LEVEL       0
    #endif //MAIN_CONFIG_LOG_ENABLED
    #include "nrf_log.h"
    NRF_LOG_MODULE_REGISTER();

    I have included the modified CLI application from SDK 16.0.0, which I used to test:

    cli_debug_sdk16.zip

  • When I build your app, I do not see the debug statements.  I am using SDK 16.0.   I guess I should have told use I was not using segger.  I am using the straight armgcc project, which was not included in your zip file, so I was forced to use my own.  My build environment is Linux so I think we have narrowed down the problem.  Not sure if the build environment affects the functionality.    Can you reproduce this cli_debug using the armgcc environment?

  • That sounds strange. SES uses GCC as the compiler, so I would not expect that to create very different output.

    I have attached an updated example with armgcc projects included. I also included precompiled HEX-files from both SES and ARMGCC that you can test:

    cli_debug_sdk16_armgcc.zip

Related