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

How to add logger library into a project?

Hi everyone,

This is my first time using Nordic nRF SDK, so i hope that I'm not asking for anything too stupid, I'm having troubles in adding nrf_logger.h into a project. I've tried to search for clues in the twi_scanner example but none of the tries have worked so far. Can anyone help me with this issue?

Compiling file: main.c
../../../main.c: In function 'handle_rx':
../../../main.c:47:17: error: implicit declaration of function 'NRF_LOG_INFO'; did you mean 'NRF_LOG_INIT'? [-Werror=implicit-function-declaration]
                 NRF_LOG_INFO("%s",NRF_LOG_PUSH(string));
                 ^~~~~~~~~~~~
                 NRF_LOG_INIT
../../../main.c:47:35: error: implicit declaration of function 'NRF_LOG_PUSH'; did you mean 'NRF_LOG_FLUSH'? [-Werror=implicit-function-declaration]
                 NRF_LOG_INFO("%s",NRF_LOG_PUSH(string));
                                   ^~~~~~~~~~~~
                                   NRF_LOG_FLUSH
cc1: all warnings being treated as errors
make: *** [../../../../../../components/toolchain/gcc/Makefile.common:272: _build/nrf52840_xxaa/main.c.o] Error 1

Parents
  • Hi,

    It can a bit of work to add the logger module to a new project because it has quite a few dependencies. I did myself for the blinky example in this thread link.  My recommendation would be to rather start with an existing example that already has the module integrated (all BLE examples do).

    Anyway, the usual logger dependencies are:

    components/libraries/log/src/nrf_log_backend_rtt.c
    components/libraries/log/src/nrf_log_backend_serial.c
    components/libraries/log/src/nrf_log_backend_uart.c
    components/libraries/log/src/nrf_log_default_backends.c
    components/libraries/log/src/nrf_log_frontend.c
    components/libraries/log/src/nrf_log_str_formatter.c
    external/segger_rtt/SEGGER_RTT.c
    external/segger_rtt/SEGGER_RTT_Syscalls_SES.c
    external/segger_rtt/SEGGER_RTT_printf.c

    And you need to make sure your sdk_config.h file contain relevenant configuration settings for the logger. Use other examples as a reference. 

Reply
  • Hi,

    It can a bit of work to add the logger module to a new project because it has quite a few dependencies. I did myself for the blinky example in this thread link.  My recommendation would be to rather start with an existing example that already has the module integrated (all BLE examples do).

    Anyway, the usual logger dependencies are:

    components/libraries/log/src/nrf_log_backend_rtt.c
    components/libraries/log/src/nrf_log_backend_serial.c
    components/libraries/log/src/nrf_log_backend_uart.c
    components/libraries/log/src/nrf_log_default_backends.c
    components/libraries/log/src/nrf_log_frontend.c
    components/libraries/log/src/nrf_log_str_formatter.c
    external/segger_rtt/SEGGER_RTT.c
    external/segger_rtt/SEGGER_RTT_Syscalls_SES.c
    external/segger_rtt/SEGGER_RTT_printf.c

    And you need to make sure your sdk_config.h file contain relevenant configuration settings for the logger. Use other examples as a reference. 

Children
No Data
Related