Skip to content

System logs not working as expected ( BUG + broken esp_log_set_vprintf ) #5954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
coratron opened this issue Dec 1, 2021 · 2 comments
Closed

Comments

@coratron
Copy link

coratron commented Dec 1, 2021

Hardware

Board: ESP32 Dev Module
Core Installation version: tested on master (v2.0.1) - part of the problem dates back to April so not new
IDE name: Platform.io on VSCode
Flash Frequency: 40Mhz
PSRAM enabled: no PSRAM
Upload Speed: 921600
Computer OS: Ubuntu

Description

The system logs were reviewed to allow access to the ESP functions so that they can be rerouted (and not just use the terminal as output).

I will refer to the post I made on a PR recently because it may fall through the cracks (it was merged a while ago):

Hi, thanks for addressing this. I found a couple of issues
@jfbuggen

  1. there is a bug on line 161 which breaks compilation if log levels are set to ERROR or higher:
    #define log_e(format, ...) do {log_to_esp(TAG, ESP_LOG_ERROR, format, ##__VA_ARGS__);}while(0)
    should be changed to
    #define log_e(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, TAG, format, ##__VA_ARGS__);}while(0)

[Note: it seems to have been right at the time of PR but somehow broken afterwards]

  1. Also, not sure why the ARDUHAL_LOG_LEVEL_NONE is formatted as ARDUHAL_LOG_LEVEL_ERROR . Perhaps not an issue but intentional?

  2. Main issue Added possibility to use ESP32-IDF log insted of redefined one #4845 was trying to address is ability to use ESP log instead of Arduino so that esp_log_set_vprintf could be used. This is now broken. Not 100% sure it is due to this change or something else in IDF functions? See below:

Example code flow:

//function used to reroute the logs
int websocket_printf(char * message, va_list args)
{
  //Serial.printf("%s\r\n", message); //this line is commented but the system crashes anyway
}

esp_log_level_set("*", ESP_LOG_ERROR);
esp_log_set_vprintf((vprintf_like_t)&websocket_printf);
log_e("%s\r\n", "hi");

This results in the following error
0x4014b063:0x3ffb27500 in s_log_level_get_and_unlock at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/log/log.c:162

If the esp_log_set_vprintf() line is commented out then the logs work via serial normally (if point 1. above is fixed first)

Originally posted by @coratron in #5081 (comment)

@coratron coratron changed the title System logs not working as expected ( BUG + broken esp_log_set_vprintf )) System logs not working as expected ( BUG + broken esp_log_set_vprintf ) Dec 1, 2021
@VojtechBartoska
Copy link
Contributor

@coratron Probably this can be closed as mentioned PR above was merged already, right?

@VojtechBartoska VojtechBartoska added the Resolution: Awaiting response Waiting for response of author label Apr 7, 2022
@VojtechBartoska
Copy link
Contributor

Closing as solved.

@VojtechBartoska VojtechBartoska added Status: Solved and removed Resolution: Awaiting response Waiting for response of author labels Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants