Customising Logs of Interest
esp_log
is the default logging component in ESP-IDF. Typically, ESP_LOGE
and ESP_LOGW
are used to log errors and warnings in the firmware. All logs recorded using the esp_log
component are tracked by the Insights agent and reported to the ESP Insights cloud. This allows developers to view these errors through the ESP Insights Dashboard, providing detailed information about what may be going on.
Developers can configure the log level by calling esp_diag_log_hook_enable()
and esp_diag_log_hook_disable()
.
/*enable tracking error logs*/
esp_diag_log_hook_enable(ESP_DIAG_LOG_TYPE_ERROR);
/*enable tracking all log levels*/
esp_diag_log_hook_enable(ESP_DIAG_LOG_TYPE_ERROR|ESP_DIAG_LOG_TYPE_WARNING|ESP_DIAG_LOG_TYPE_EVENT);
/*disable tracking custom events*/
esp_diag_log_hook_disable(ESP_DIAG_LOG_TYPE_EVENT);
Normally, some error or warning logs are printed before the device crashes, which are hard to be reported to the cloud. ESP Insights agent provides a way to keep the logs and report them to the ESP Insights cloud after boot-up. ESP32-C3 is equipped with RTC memory. The Insights agent uses this memory to store the critical errors that occurred in the system. On any boot-up, the Insights agent will check for any unreported errors from the previous boot-up through this RTC memory and report that to the ESP Insights cloud.