espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
12.89k stars 7.08k forks source link

ESP_LOG unix timestamp (IDFGH-13066) #14011

Open nebkat opened 2 weeks ago

nebkat commented 2 weeks ago

Is your feature request related to a problem?

ESP_LOG offers choice of milliseconds since boot or system time: HH:MM:SS and YY-MM-DD since https://github.com/espressif/esp-idf/commit/4ad9ad80860059f9963fabf070b3ccbcb6501a8d.

The YY-MM-DD option is the only one which uniquely identifies the time when the log was printed, but this requires 21 bytes and has to be parsed if the log lines are being analyzed by another tool.

Describe the solution you'd like.

An option to print unix timestamp in format 1718712039103 (milliseconds) - 13 bytes.

Describe alternatives you've considered.

No response

Additional context.

Depending on the application human readable or unix timestamp may be preferable, however in my case there is no value in knowing the date/time, just need the ability to find corresponding timestamp entries in a database.

nebkat commented 2 weeks ago

@KonstantinKondrashov if you could consider this addition, or let me know if you would like a PR for it.

KonstantinKondrashov commented 2 weeks ago

Hi @nebkat! I have a merge request in our internal repo that adds this feature as well. It is about in the review stage now. I hope it will appear on master within 1-2 weeks.

        config LOG_TIMESTAMP_SOURCE_NONE
            bool "None"
        config LOG_TIMESTAMP_SOURCE_RTOS
            bool "Milliseconds Since Boot"
        config LOG_TIMESTAMP_SOURCE_SYSTEM
            bool "System Time (HH:MM:SS.sss)"
        config LOG_TIMESTAMP_SOURCE_SYSTEM_FULL
            bool "System Time (YY-MM-DD HH:MM:SS.sss)"

Additionally, there will be a new time function using which will allow you to change the time format as you wish if needed.

nebkat commented 2 weeks ago

@KonstantinKondrashov I see the above options in master - specifically I was referring to unix timestamp rather than date/time, but if that is what you meant or if there is a custom timestamp option then that will do just fine. Thanks!

KonstantinKondrashov commented 1 week ago

Hi @nebkat! I will add the "unix timestamp in milliseconds" option too. It makes sense to have it. Implementing your own timestamp format will be also possible with the new changes.