-
Notifications
You must be signed in to change notification settings - Fork 183
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
enable logging with milliseconds since boot and system time in rust logs depending on configuration #494
Conversation
My one concern with this PR is that we would start using a logging API - which is - IMO - flawed. The TL;DR is, I also do not understand the counter-arguments of both @igrr and @ESP_Sprite (not really sure what is his GH id to ping him here) where they say that - to paraphrase - "you would still read a properly formatted timestamp, even if the internal buffer is being modified while you are reading". Folks, while I get it that it is impossible - by just reading the internal buffer of Imagine that the timestamp which is being read right now is "23:59:59" and the reading code read (and printed) only the first digit, i.e. "2" and then the scheduler kicked-in and re-scheduled the task because of - whatever - maybe the UART is full and we need to IO-wait or really whatever. If - in the meantime - another thread calls @igrr - What am I missing? |
@igrr ? |
Before writing my comment I would like to clarify the function signatures in the comment above as this mixup can be confusing: I think every mention above of I fully understand your concern and see the problem with the library code and why it is flawed. Starting here some questions form in my head.
What I wanted to achieve with this pull request in the first place is to finally have logging for my devices that contain an absolute timestamp (once NTP was successful) and not just a relative number to some "random" starting point. I also wanted to leverage the existing functions from RTOS as otherwise my logs get mixed with different timestamp formats depending on where they come from (RTOS vs Rust). |
Thanks for the thorough explanation. Judging from the speed of this and other responses from the ESP-IDF team, I don't think we would be getting any reply soon with regards to whether they plan to fix the data race issue or not, nor info what is the planned future for the Your argument that at least we would be consistent (with data-races included as a bonus) with whatever ESP IDF does w.r.t. logging is a strong one though. How about the following: we take your existing approach, using the racy It would also be great if you could include - in a code comment - a link to this discussion over here. If you do these, I would merge this PR. |
As for the code duplication - some code duplication between the native ESP IDF log macros and the The reason for this is because we cannot really reuse the ESP IDF vsprint logging machinery without doing allocations (or at least I did not find out how). So if we would like to have a "quick" logging (and we probably do, as logging can be done in tight places) we need to duplicate. |
…idf_log_timestamp_source_system for system time in rust logging
added the TODO comment |
I could not find in the code a link to this discussion, but oh well, I guess I'll remember it. Many thanks! |
thank you for merging it. I included the TODO in my original commit |
CONFIG_LOG_TIMESTAMP_SOURCE_RTOS is the correct configuration value. In the source code currently: cfg!(esp_idf_log_timestamp_rtos) |
To clarify, the word "source" is missing. cfg!(esp_idf_log_timestamp_source_rtos) |
This change allows to set one of these configurations
source: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig.html#config-log-timestamp-source
I'm open for suggestions on how to properly structure this as I'm not sure how to do this kind of conditional selection of what to print as the original timestamp is u32 and I wanted to avoid having another nested case distinction inside both color paths.
This allows timestamps like the following if CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is set