In esp_hal_log.h there are some changes to logging format, esp adding a millisecond timestamp by default
as I already have a logging extension in place that outputs actual timestamp in stead of milliseconds since last boot, I want to ignore this change.
esp-hal-Log.h does contain a simple format in a macro called ARDUHAL_SHORT_LOG_FORMAT but I can;t seem to find a way to make the logging use this format in stead of the ARDUHAL_LOG_FORMAT used now.
How can I do this?
How to use ARDUHAL_SHORT_LOG_FORMAT
Re: How to use ARDUHAL_SHORT_LOG_FORMAT
Hi,
I was wondering the same and I found one solution. I didn't wanted to change the file esp_hal_log.h, so instead I just added this into my own application file (for example main.cpp):
You also can redefine it to anything else you want. For example just remove the time:
It works at least for my code but not for the code that uses the logging which is called to start my code (the part before setup() and loop()).
You could also change the code directly in esp_hal_log.h but then you might need to remember it when this part is updated or you hand the code to somebody else who does not have the change in the library.
I was wondering the same and I found one solution. I didn't wanted to change the file esp_hal_log.h, so instead I just added this into my own application file (for example main.cpp):
- #include <esp32-hal-log.h>
- #undef ARDUHAL_LOG_FORMAT
- #define ARDUHAL_LOG_FORMAT(letter, format) ARDUHAL_SHORT_LOG_FORMAT(letter, format)
You also can redefine it to anything else you want. For example just remove the time:
- #include <esp32-hal-log.h>
- #undef ARDUHAL_LOG_FORMAT
- #define ARDUHAL_LOG_FORMAT(letter, format) ARDUHAL_LOG_COLOR_ ## letter "[" #letter "][%s:%u] %s(): " format ARDUHAL_LOG_RESET_COLOR "\r\n", pathToFileName(__FILE__), __LINE__, __FUNCTION__
You could also change the code directly in esp_hal_log.h but then you might need to remember it when this part is updated or you hand the code to somebody else who does not have the change in the library.
Who is online
Users browsing this forum: No registered users and 78 guests