Skip to content

ESP_LOGX is broken with no suitable alternative #4264

Closed
@az-z

Description

@az-z

ESP_LOGX, as well as, all related "infrastructure" has been broken for a while now.
we can not assign TAGS, nor control the amount of logging per unit in any other way, but changing CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL app level variable.

Based on the discussion in #585 (closed) the solution was introduced -> to use log_x .
Unfortunately, log_x is not a replacement, but a "hack".
In addition, this hack broke esp_log_write() and esp_log_set_vprintf() functionality.

static const char *TAG = "AW";
...

int double_vprintf(const char *fmt, va_list args) {

	char buffer[256];
	int ret = vsnprintf (buffer, sizeof(buffer), fmt, args);
	ESP_LOGI("from withing double_vprintf...");

// The following requires AWS_IOT library and configuration for AWS and MQQT. But you can reproduce the same "not working" situation by poiinting to a file
	if (hornbill.publish(TOPIC_NAME,buffer) != 0) {
		Serial.println("Sending data from double_vprintf() failed");
		ESP_LOGE("Sending data from double_vprintf() failed");
	};
	return vprintf(fmt, args);
}


void setup() {
	delay(3000);
	Serial.begin(9600);

	esp_log_level_set("*",ESP_LOG_INFO);
	esp_log_level_set(TAG,ESP_LOG_INFO);
	esp_log_level_set("WIFI",TAG,ESP_LOG_INFO);

...
	esp_log_set_vprintf(double_vprintf);
	ESP_LOGI(TAG," INFO");
	ESP_LOGE(TAG,"ERROR - why do i see it? I set to INFO only!");
	esp_log_set_vprintf(double_vprintf);
}


Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions