-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the option to print system time rather than RTOS time in ESP_LOGx functions (IDFGH-1773) #3958
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Frosticles,
Thanks for contributing this, it looks like a very useful change for some users.
I have a couple of minor requests but overall looks great.
I've added in the requests from @projectgus, given it a quick test my end and all seems well. Please do comment on any other changes you'd like but otherwise I'm happy to merge this for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick update @Frosticles and for being patient while I got back to you.
A couple of small things, one idea I didn't think of the first time around (sorry).
Also a very minor thing: the IDF code style is to put the opening brace of a statement on the same line as the statement, ie
if ((timestamp > 0) || (i == 0)) {
components/log/log.c
Outdated
|
||
if (bufferLock == 0) | ||
{ | ||
_lock_init(&bufferLock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newlib locks actually lazy initialize, so you don't need this init check (the lock will be initialized the first time _lock_acquire()
is called.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, didn't know that, I'll remove this bit
Thanks again @Frosticles . I've squashed the commits and pushed them into our internal review & merge queue. This PR will be updated again once that process is complete. |
Apologies for the late commit, not sure how I missed that but cppcheck spotted that I was accessing that buffer array out of bounds, just pushed a fix. |
@Frosticles Thanks, can't believe we both missed that! Have updated our internal branch, should be merged soon (has been a national holiday in China so things got a little delayed). |
|
I mainly wrote this because I wanted to syncronize logs from an ESP32 with logs from a cloud platform that were timestamped in UTC, and I think other people would probably find this option useful too.
Obviously this time will just start from 0 unless you set the system time (with an SNTP sync for example), but assuming you do set the time it makes the logs much more useful when trying to match up events happening on multiple platforms.
Example from the hello world program: