Page 1 of 1

ESP_LOG(I/W/E) vs printf for debug

Posted: Thu Apr 12, 2018 12:59 pm
by mikemoy
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.

Re: ESP_LOG(I/W/E) vs printf for debug

Posted: Thu Apr 12, 2018 1:44 pm
by ESP_krzychb
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.
Hi mikemoy,

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

Posted: Thu Apr 12, 2018 2:17 pm
by mikemoy
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

Posted: Thu Apr 12, 2018 5:04 pm
by kolban
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.

Re: ESP_LOG(I/W/E) vs printf for debug

Posted: Mon Apr 16, 2018 7:01 am
by meowsqueak
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.