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
  • 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

Reply
  • 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

Children
  • Could you try setting CONFIG_LOG_MODE_DEFERRED = y

    -Priyanka

  • Hi,

    I will attach the prj.conf with some modifications. Kindly let me know if this works or even if there is a change in the error logs.

    Regards,

    Priyanka

    4377.prj.conf

  • Unfortunately it doesn't work. Both CONFIG_LOG_MINIMAL and CONFIG_LOG_DEFAULT_MINIMAL will cause compilation error:

    //==============================================================================

    -- west build: generating a build system
    Including boilerplate (Zephyr base): C:/work/ncs/zephyr/cmake/app/boilerplate.cmake
    -- Application: C:/work/bbotg/spot/fw9160
    -- Zephyr version: 2.6.99 (C:/work/ncs/zephyr), build: v2.6.99-ncs1-1
    -- Found Python3: C:/Python39/python.exe (found suitable exact version "3.9.6") found components: Interpreter
    -- Found west (found suitable version "0.11.0", minimum required is "0.7.1")
    -- Board: nrf9160dk_nrf9160_ns, Revision: 0.7.0
    -- Cache files will be written to: C:/work/ncs/zephyr/.cache
    -- Found toolchain: gnuarmemb (C:/gnuarmemb)
    -- Found BOARD.dts: C:/work/ncs/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns.dts
    -- Generated zephyr.dts: C:/work/bbotg/spot/fw9160/build_nrf9160dk/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: C:/work/bbotg/spot/fw9160/build_nrf9160dk/zephyr/include/generated/devicetree_unfixed.h
    -- Generated device_extern.h: C:/work/bbotg/spot/fw9160/build_nrf9160dk/zephyr/include/generated/device_extern.h
    -- Including generated dts.cmake file: C:/work/bbotg/spot/fw9160/build_nrf9160dk/zephyr/dts.cmake

    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.


    C:/work/bbotg/spot/fw9160/prj.conf:22: warning: attempt to assign the value 'n' to the undefined symbol LOG_DEFAULT_MINIMAL
    Parsing C:/work/bbotg/spot/fw9160/Kconfig
    Loaded configuration 'C:/work/ncs/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns_defconfig'
    Merged configuration 'C:/work/bbotg/spot/fw9160/prj.conf'

    error: Aborting due to Kconfig warnings

    CMake Error at C:/work/ncs/zephyr/cmake/kconfig.cmake:268 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      C:/work/ncs/zephyr/cmake/app/boilerplate.cmake:554 (include)
      C:/work/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/work/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
      CMakeLists.txt:9 (find_package)


    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' '-DWEST_PYTHON=c:\python39\python.exe' '-BC:\work\bbotg\spot\fw9160\build_nrf9160dk' '-SC:\work\bbotg\spot\fw9160' -GNinja -DBOARD=nrf9160dk_nrf9160_ns
    ##### program target #####
    -- west flash: rebuilding
    Error: could not find CMAKE_PROJECT_NAME in Cache
    FATAL ERROR: re-build in build_nrf9160dk failed

    //==============================================================================

    If I remove both, it compiles. But then there's no timestamp.

  • Hi,

    It looks like all the error messages have the LOG_MINIMAL condition unsatisfied. This could be wrong, but could you try setting CONFIG_LOG_MINIMAL=y ?

    -Priyanka

Related