Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using of NRF_LOG_INFO without a new line and correct using of the log functions

Hello,

I try to use those functions for printing log massages on the Segger RTT terminal, but I have many problems with that.

1. How can I use this function without printing of new line? The meaning - I want to print dots (...) when nothing happens, but cannot - each dot is printed with a new line.

2. I need all prints from my applications: from interrupts, events, error handlers and etc, but I don't get it. Some of messages are printed, but many are not. I'm extremely cannot understand what is happened in my application (BLE NUS application, with transfer files and commands, event driven)

I'm very appreciate for help!

Thanks a lot!

Parents
  • Hi,

    1. Are you using deferred logging? If so, your messages won't be printed before you call NRF_LOG_FLUSH() or NRF_LOG_FINAL_FLUSH(). If your application asserts before you call these functions you won't see your messages. Make sure to read the Logger module documentation to understand how it all connects.
    2. Are you saying that instead of getting dots on the same line you get:
      .
      .
      .
      ?
      If you use NRF_LOG_INFO("..."); you should see three dots one after another. There is no way around the "0> <info> app:" text that also usually shows up at the beginning of the line though.
    3. Are you using RTT or UART as backend. 

    Another thing you can do to make sure all your logging info is printed in case of an assert is to define your own app_error_fault_handler() function:

    void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
    {
        NRF_LOG_INFO("My fault handler");
        /* Print your info messages */
        NRF_LOG_FINAL_FLUSH();
        while(1);
    }

Reply
  • Hi,

    1. Are you using deferred logging? If so, your messages won't be printed before you call NRF_LOG_FLUSH() or NRF_LOG_FINAL_FLUSH(). If your application asserts before you call these functions you won't see your messages. Make sure to read the Logger module documentation to understand how it all connects.
    2. Are you saying that instead of getting dots on the same line you get:
      .
      .
      .
      ?
      If you use NRF_LOG_INFO("..."); you should see three dots one after another. There is no way around the "0> <info> app:" text that also usually shows up at the beginning of the line though.
    3. Are you using RTT or UART as backend. 

    Another thing you can do to make sure all your logging info is printed in case of an assert is to define your own app_error_fault_handler() function:

    void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
    {
        NRF_LOG_INFO("My fault handler");
        /* Print your info messages */
        NRF_LOG_FINAL_FLUSH();
        while(1);
    }

Children
Related