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

How to add Logging module to an app

I need logging in almost anything I do, but I've never been able to start from an example that does not use logging and add logging.  I've set the NRF_LOG_ENABLED and NRF_LOG_BACKEND_SERIAL_USES_UART flag.  I've repeatedly built, fixing compile and link errors by adding include paths and source files until it builds.  Even then, it rarely works.  I'd prefer logging to UART, but right now I'll take anything.

Is there a documented way to add logging to an app?  One that has a decent chance of working the first time?  Concretely, if I can figure out how add logging to Blinky, I'll be a long way toward doing it in general.

Rob

Parents
  • I'm going to answer this myself.  There is no documentation, just examples.  It looks like the process is as follows:

    1) Find an example that uses Logging

    2) Merge the nrf_log sections from the example's sdk_config.h

    2) Add NRF_LOG_INIT and NRF_LOG_DEFAULT_BACKENDS_INIT to your code

    3) Add obvious nrf_log .c files and header paths from the reference example

    4) Repeatedly build until you find all the non-obvious .c files and header paths

    5) With luck, it will work

    6) Remember what you changed so you can do it again for another project.

    I haven't tried to be 100% accurate, above, so I may have left out steps.

Reply
  • I'm going to answer this myself.  There is no documentation, just examples.  It looks like the process is as follows:

    1) Find an example that uses Logging

    2) Merge the nrf_log sections from the example's sdk_config.h

    2) Add NRF_LOG_INIT and NRF_LOG_DEFAULT_BACKENDS_INIT to your code

    3) Add obvious nrf_log .c files and header paths from the reference example

    4) Repeatedly build until you find all the non-obvious .c files and header paths

    5) With luck, it will work

    6) Remember what you changed so you can do it again for another project.

    I haven't tried to be 100% accurate, above, so I may have left out steps.

Children
No Data
Related