mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-03 22:06:32 +02:00
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:
@ -12,14 +12,7 @@
|
||||
#include <iomanip>
|
||||
#include "FreeRTOS.h"
|
||||
#include "sdkconfig.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 = "FreeRTOS";
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Sleep for the specified number of milliseconds.
|
||||
@ -67,7 +60,7 @@ uint32_t FreeRTOS::getTimeSinceStart() {
|
||||
* @return The value associated with the semaphore.
|
||||
*/
|
||||
uint32_t FreeRTOS::Semaphore::wait(std::string owner) {
|
||||
ESP_LOGV(LOG_TAG, ">> wait: Semaphore waiting: %s for %s", toString().c_str(), owner.c_str());
|
||||
log_v(">> wait: Semaphore waiting: %s for %s", toString().c_str(), owner.c_str());
|
||||
|
||||
if (m_usePthreads) {
|
||||
pthread_mutex_lock(&m_pthread_mutex);
|
||||
@ -83,7 +76,7 @@ uint32_t FreeRTOS::Semaphore::wait(std::string owner) {
|
||||
xSemaphoreGive(m_semaphore);
|
||||
}
|
||||
|
||||
ESP_LOGV(LOG_TAG, "<< wait: Semaphore released: %s", toString().c_str());
|
||||
log_v("<< wait: Semaphore released: %s", toString().c_str());
|
||||
m_owner = std::string("<N/A>");
|
||||
return m_value;
|
||||
} // wait
|
||||
@ -117,7 +110,7 @@ FreeRTOS::Semaphore::~Semaphore() {
|
||||
* The Semaphore is given.
|
||||
*/
|
||||
void FreeRTOS::Semaphore::give() {
|
||||
ESP_LOGV(LOG_TAG, "Semaphore giving: %s", toString().c_str());
|
||||
log_v("Semaphore giving: %s", toString().c_str());
|
||||
if (m_usePthreads) {
|
||||
pthread_mutex_unlock(&m_pthread_mutex);
|
||||
} else {
|
||||
@ -162,7 +155,7 @@ void FreeRTOS::Semaphore::giveFromISR() {
|
||||
* @return True if we took the semaphore.
|
||||
*/
|
||||
bool FreeRTOS::Semaphore::take(std::string owner) {
|
||||
ESP_LOGD(LOG_TAG, "Semaphore taking: %s for %s", toString().c_str(), owner.c_str());
|
||||
log_d("Semaphore taking: %s for %s", toString().c_str(), owner.c_str());
|
||||
bool rc = false;
|
||||
if (m_usePthreads) {
|
||||
pthread_mutex_lock(&m_pthread_mutex);
|
||||
@ -171,9 +164,9 @@ bool FreeRTOS::Semaphore::take(std::string owner) {
|
||||
}
|
||||
m_owner = owner;
|
||||
if (rc) {
|
||||
ESP_LOGD(LOG_TAG, "Semaphore taken: %s", toString().c_str());
|
||||
log_d("Semaphore taken: %s", toString().c_str());
|
||||
} else {
|
||||
ESP_LOGE(LOG_TAG, "Semaphore NOT taken: %s", toString().c_str());
|
||||
log_e("Semaphore NOT taken: %s", toString().c_str());
|
||||
}
|
||||
return rc;
|
||||
} // Semaphore::take
|
||||
@ -187,7 +180,7 @@ bool FreeRTOS::Semaphore::take(std::string owner) {
|
||||
* @return True if we took the semaphore.
|
||||
*/
|
||||
bool FreeRTOS::Semaphore::take(uint32_t timeoutMs, std::string owner) {
|
||||
ESP_LOGV(LOG_TAG, "Semaphore taking: %s for %s", toString().c_str(), owner.c_str());
|
||||
log_v("Semaphore taking: %s for %s", toString().c_str(), owner.c_str());
|
||||
bool rc = false;
|
||||
if (m_usePthreads) {
|
||||
assert(false); // We apparently don't have a timed wait for pthreads.
|
||||
@ -196,9 +189,9 @@ bool FreeRTOS::Semaphore::take(uint32_t timeoutMs, std::string owner) {
|
||||
}
|
||||
m_owner = owner;
|
||||
if (rc) {
|
||||
ESP_LOGV(LOG_TAG, "Semaphore taken: %s", toString().c_str());
|
||||
log_v("Semaphore taken: %s", toString().c_str());
|
||||
} else {
|
||||
ESP_LOGE(LOG_TAG, "Semaphore NOT taken: %s", toString().c_str());
|
||||
log_e("Semaphore NOT taken: %s", toString().c_str());
|
||||
}
|
||||
return rc;
|
||||
} // Semaphore::take
|
||||
|
Reference in New Issue
Block a user