Refactored use of LOG_X(LOG_TAG, ...) to log_x(...) (#2672)

* Replaced ARDUINO_VARIANT with const char

* Fixed missing return value

* Added quotes around defined value in macro (Issue #2193)

* Change logging from Error to Verbose when not found and default available

* Move Enter and Exit logging to Verbose Level

* Refactored LOG_X() into log_x()
This commit is contained in:
Bascy
2019-04-15 17:26:35 +02:00
committed by Me No Dev
parent af23d0bb10
commit 01d7ea7b80
21 changed files with 399 additions and 530 deletions

View File

@ -18,15 +18,7 @@
#include <esp_wifi.h>
#include <esp_heap_caps.h>
#include <esp_system.h>
#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG)
#include "esp32-hal-log.h"
#define LOG_TAG ""
#else
#include "esp_log.h"
static const char* LOG_TAG = "GeneralUtils";
#endif
static const char kBase64Alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
@ -115,11 +107,11 @@ void GeneralUtils::dumpInfo() {
size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_8BIT);
esp_chip_info_t chipInfo;
esp_chip_info(&chipInfo);
ESP_LOGV(LOG_TAG, "--- dumpInfo ---");
ESP_LOGV(LOG_TAG, "Free heap: %d", freeHeap);
ESP_LOGV(LOG_TAG, "Chip Info: Model: %d, cores: %d, revision: %d", chipInfo.model, chipInfo.cores, chipInfo.revision);
ESP_LOGV(LOG_TAG, "ESP-IDF version: %s", esp_get_idf_version());
ESP_LOGV(LOG_TAG, "---");
log_v("--- dumpInfo ---");
log_v("Free heap: %d", freeHeap);
log_v("Chip Info: Model: %d, cores: %d, revision: %d", chipInfo.model, chipInfo.cores, chipInfo.revision);
log_v("ESP-IDF version: %s", esp_get_idf_version());
log_v("---");
} // dumpInfo
@ -237,7 +229,7 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
if (index % 16 == 0) {
strcpy(hexBuf, hex.str().c_str());
strcpy(asciiBuf, ascii.str().c_str());
ESP_LOGV(tag, "%s %s", hexBuf, asciiBuf);
log_v("%s %s", hexBuf, asciiBuf);
hex.str("");
ascii.str("");
}
@ -249,8 +241,8 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
}
strcpy(hexBuf, hex.str().c_str());
strcpy(asciiBuf, ascii.str().c_str());
ESP_LOGV(tag, "%s %s", hexBuf, asciiBuf);
//ESP_LOGV(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
log_v("%s %s", hexBuf, asciiBuf);
//log_v("%s %s", hex.str().c_str(), ascii.str().c_str());
}
FreeRTOS::sleep(1000);
}
@ -272,7 +264,7 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
}
index++;
if (index % 16 == 0) {
ESP_LOGV(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
log_v("%s %s", hex.str().c_str(), ascii.str().c_str());
hex.str("");
ascii.str("");
}
@ -282,7 +274,7 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
hex << " ";
index++;
}
ESP_LOGV(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
log_v("%s %s", hex.str().c_str(), ascii.str().c_str());
}
FreeRTOS::sleep(1000);
}
@ -302,8 +294,8 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
char tempBuf[80];
uint32_t lineNumber = 0;
ESP_LOGV(LOG_TAG, " 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f");
ESP_LOGV(LOG_TAG, " -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
log_v(" 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f");
log_v(" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
strcpy(ascii, "");
strcpy(hex, "");
uint32_t index = 0;
@ -318,7 +310,7 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
strcat(ascii, tempBuf);
index++;
if (index % 16 == 0) {
ESP_LOGV(LOG_TAG, "%.4x %s %s", lineNumber * 16, hex, ascii);
log_v("%.4x %s %s", lineNumber * 16, hex, ascii);
strcpy(ascii, "");
strcpy(hex, "");
lineNumber++;
@ -329,7 +321,7 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
strcat(hex, " ");
index++;
}
ESP_LOGV(LOG_TAG, "%.4x %s %s", lineNumber * 16, hex, ascii);
log_v("%.4x %s %s", lineNumber * 16, hex, ascii);
}
} // hexDump