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

  • I have mentioned earlier that I can't set CONFIG_LOG_MINIMAL. See the error log below.

    =====================================================================

    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: LOG_MINIMAL (defined at subsys/logging\Kconfig.mode:74) is assigned in a configuration file,
    but is not directly user-configurable (has no prompt). It gets its value indirectly from other
    symbols. See docs.zephyrproject.org/.../CONFIG_LOG_MINIMAL.html and/or
    look up LOG_MINIMAL 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.

    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:40 (include_boilerplate)
      CMakeLists.txt:9 (find_package)

  • Hi,

    This is the latest documentation for CONFIG_LOG_BACKEND_FORMAT_TIMESTAMP and there are some changes to the direct dependencies. Could you try removing the CONFIG_LOG_MINIMAL from your prj.conf as this is no longer a direct dependency? 

    And still if the error persists, could you once again upload your prj.conf?

    -Priyanka

Related