Zephyr logger: how to enable timestamp

I'm using the logger (LOG_INF, LOG)_DBG...etc) to print out debug messages. I'd like to have timestamp printed out. Right now it looks like this: D: xxxx or I: xxxxx

I found 3 CONFIGs that has the word timestamp in it. But seems none of them work. I'm not sure if I'm looking at the right direction.

CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP

CONFIG_LOG_TIMESTAMP_64BIT

CONFIG_LOG_TRACE_SHORT_TIMESTAMP

So how to enable times tamping in logging?

Another logger question is, I keep getting warning like this.

"warning: LOG_BACKEND_RTT (defined at subsys/logging\Kconfig.backends:87) was assigned the value 'y'
but got the value 'n'. Check these unsatisfied dependencies: (!LOG_MINIMAL) (=n). See
docs.zephyrproject.org/.../CONFIG_LOG_BACKEND_RTT.html and/or look up
LOG_BACKEND_RTT in the menuconfig/guiconfig interface. The Application Development Primer, Setting
Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
too."

Looking up the document, there's no LOG_MINIMAL, only LOG_MODE_MINIAL. And whether I set it or not, it appears RTT is working because I can see output from RTT window so it must be working. I wonder what the warning message mean?

Thanks!

Parents Reply Children
  • I don't understand how this apply to my case. I'm using Zephyr with NCS 1.7.

  • Hi,

    I'm really sorry for the wrong links. Thanks for letting me know. You could try using one of the CONFIG that you mentioned,

    CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP

    Also, you can see that the following is the conditions for enabling the CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP

    depends on (LOG_BACKEND_UART || LOG_BACKEND_NATIVE_POSIX || LOG_BACKEND_RTT || LOG_BACKEND_SWO || LOG_BACKEND_XTENSA_SIM || LOG_BACKEND_FS) && !LOG_FRONTEND && !LOG_MODE_MINIMAL && LOG

    It has direct dependencies on LOG_BACKEND_RTT. Hence, you should also set the CONFIG_LOG_BACKEND_RTT = y

    Also, CONFIG_LOG_FRONTEND = n, CONFIG_LOG_MODE_MINIMAL = n  and CONFIG_LOG = y should be set.

    The LOG_MINIMAL is set according to the LOG_MODE_MINIMAL.

    Any config that you wish to implement should be checked for any direct dependencies and those should also be enabled or disabled accordingly.

    Hope this helps.

    Regards,

    Priyanka

  • Hi,

    I try to do what you described here. But it doesn't work.I keep getting the following warning message during build. I suspect there's something wrong with the build. Particularly I can specify CONFIG_LOG_MINIMAL as the warning message says it can't be set directly. Instead I used CONFIG_LOG_MODE_MINIMAL but it doesn't seem working. The several logging related warning seems all have something to do with the CONFIG_LOG_MINIMAL.

    I also attached the prj.conf from my project if you could take a look.

    Thanks!

    /////////////////////////////////////////////

    warning: LOG_BACKEND_FORMAT_TIMESTAMP (defined at subsys/logging\Kconfig.formatting:61) was assigned
    the value 'y' but got the value 'n'. Check these unsatisfied dependencies: (LOG_BACKEND_UART ||
    LOG_BACKEND_NATIVE_POSIX || LOG_BACKEND_RTT || LOG_BACKEND_SWO || LOG_BACKEND_XTENSA_SIM ||
    LOG_BACKEND_FS) (=n), (!LOG_MINIMAL) (=n). See
    docs.zephyrproject.org/.../CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP.html
    and/or look up LOG_BACKEND_FORMAT_TIMESTAMP in the menuconfig/guiconfig interface. The Application
    Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of
    the manual might be helpful too.


    warning: LOG_PROCESS_THREAD (defined at subsys/logging\Kconfig.processing:58) was assigned the value
    'y' but got the value 'n'. Check these unsatisfied dependencies: (!LOG_MINIMAL) (=n), (!LOG_MINIMAL)
    (=n). See docs.zephyrproject.org/.../CONFIG_LOG_PROCESS_THREAD.html
    and/or look up LOG_PROCESS_THREAD in the menuconfig/guiconfig interface. The Application Development
    Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
    might be helpful too.


    warning: LOG_BUFFER_SIZE (defined at subsys/logging\Kconfig.processing:101) was assigned the value
    '8192' but got the value ''. Check these unsatisfied dependencies: (!LOG_MINIMAL) (=n),
    (!LOG_MINIMAL) (=n). See
    docs.zephyrproject.org/.../CONFIG_LOG_BUFFER_SIZE.html and/or look up
    LOG_BUFFER_SIZE in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.


    warning: LOG_BACKEND_UART (defined at subsys/logging\Kconfig.backends:6) was assigned the value 'y'
    but got the value 'n'. Check these unsatisfied dependencies: (!LOG_MINIMAL) (=n). See
    docs.zephyrproject.org/.../CONFIG_LOG_BACKEND_UART.html and/or look up
    LOG_BACKEND_UART in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.

    ////////////////////////////////////////////////////////

    7776.prj.conf

  • Could you try setting CONFIG_LOG_MODE_DEFERRED = y

    -Priyanka

Related