I notice that there are 2 camps for debugging via the serial port.
Those that use ESP_LOG(I/W/E), and those that use printf.
I am in the camp of printf because there is less typing involved to get the job done. But I am open to see if there is something I don't know about with using ESP_LOG(I/W/E).
Is this just a matter of preference, or is there a logical reason to use ESP_LOG(I/W/E) over "I've seen it done so that's why I do it" type mentality.
ESP_LOG(I/W/E) vs printf for debug
- ESP_krzychb
- Posts: 400
- Joined: Sat Oct 01, 2016 9:05 am
- Contact:
Re: ESP_LOG(I/W/E) vs printf for debug
Hi mikemoy,mikemoy wrote:Is this just a matter of preference, or is there a logical reason to use ESP_LOG(I/W/E) over "I've seen it done so that's why I do it" type mentality.
I think that for most of ad hoc debuging this it is a matter of preference with indication to use printf.
ESP_LOG(I/W/E) are intended to implement "permanent" logging functionality in the code and is also used in the ESP-IDF itself. Then depending on debugging scenario it is possible to globally or locally enable required verbosity levels of information to receive.
There are cases of ad hoc logging where ESP_LOG(I/W/E) is more appropriate, see Logging to Host via JTAG.
Re: ESP_LOG(I/W/E) vs printf for debug
For myself, I did not like the fact that through menuconfig I could only select one of the 5 options. They should let you select as many as you like. For instance, I could not select Error and Debug.
Re: ESP_LOG(I/W/E) vs printf for debug
I think the notion of logging levels including "encapsulated" logging levels is pretty well the common. For example, in Java land:
https://www.tutorialspoint.com/log4j/lo ... levels.htm
Maps:
ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF.
https://www.tutorialspoint.com/log4j/lo ... levels.htm
Maps:
ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 151
- Joined: Thu Jun 15, 2017 4:54 am
- Location: New Zealand
Re: ESP_LOG(I/W/E) vs printf for debug
I like the ESP_LOGx macros because you can enable/disable them at runtime. For example, hook up some appropriate MQTT topics and you've got yourself a run-time selectable debug log.
Re: ESP_LOG(I/W/E) vs printf for debug
Hello,
I write two very interesting stories on medium about "ESP_LOGx vs printf" and "Remote control on logs for enabling/disable logs". I think it's interesting for you to check this out.
ESP_LOGx vs printf
https://medium.com/@markevens36/esp-idf ... e24bd6fe78
Remote control on logs
https://medium.com/@markevens36/esp-idf ... 24acb28218
I write two very interesting stories on medium about "ESP_LOGx vs printf" and "Remote control on logs for enabling/disable logs". I think it's interesting for you to check this out.
ESP_LOGx vs printf
https://medium.com/@markevens36/esp-idf ... e24bd6fe78
Remote control on logs
https://medium.com/@markevens36/esp-idf ... 24acb28218
Re: ESP_LOG(I/W/E) vs printf for debug
I also figured out that printf can get buggy. I regularly miss text from a printf, partially or even totally while this seems to never happen on the ESP_LOGx ; I suppose this is related to thread behavior, printf most likely isn't thread safe whereas ESP_LOGx looks like to be.
Who is online
Users browsing this forum: No registered users and 96 guests