Skip to content

esp_log_set_vprintf doesnt process correctly the log messages from sketch #2021

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
robertgregor opened this issue Nov 5, 2018 · 6 comments
Closed
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@robertgregor
Copy link

Hi, I want to redirect the logging to the internal buffer to be available for the webpage instead of serial port.

There is a function in the esp-idf - esp_log_set_vprintf. It works, however, it doesn't work for the messages in arduino sketch, only the idf messages are displayed...

I have it like that:

#include "esp_log.h"
#include "esp_system.h"

int buffer_logging_vprintf( const char *str, va_list l ) {
Serial.println("aaaaaaa");
}

void setup(){
esp_log_level_set("*", ESP_LOG_VERBOSE);
esp_log_set_vprintf(buffer_logging_vprintf);
Serial.begin(115200);
log_i("Infoooooooo");
}

I expected output like only the aaaaaaa. However, the real output looks like:

[I][TestAsync.ino:316] setup(): Infoooooooo
[I][TestAsync.ino:102] connectToWifi(): Connecting wifi...
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
[W][WiFiGeneric.cpp:360] _eventCallback(): Reason: 2 - AUTH_EXPIRE
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
[I][TestAsync.ino:54] print_wakeup_reason(): Wakeup was not caused by deep sleep
[I][TestAsync.ino:338] setup(): Connected to AP in 4281 ms. IP: 192.168.1.50
[I][TestAsync.ino:342] setup(): Module time: 2018-11-06 00:04:48
[I][TestAsync.ino:348] setup(): Voltage: 3.32V
[I][TestAsync.ino:350] setup(): Starting Web server...

So as is seen, the idf messages are redirected correctly, but not the messages from sketch.

Any idea?

Robert

@robertgregor
Copy link
Author

I see why:
In fact the preprocessor will replace the esp_idf log_i with log_printf( "[" "I" "][%s:%u] %s()...........
I don't think, that this is correct. Why it is not replaced by the esp_idf function - log_i and thus, it will have the same format and same functionality like the other classes???

@GeorgeFlorian
Copy link

Hello ! I've been trying to use esp_log_set_vprintf for the past week and I can't make it work.
I would like to redirect the log messages to a SPIFFS file and then to read them from that file.

Did you fix this ? Did you manage to use esp_log_set_vprintf to redirect your log messages ?

Thank you !

@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Aug 15, 2019
@tbertels
Copy link
Contributor

tbertels commented Oct 5, 2021

See also #4346

@letmeknowFR
Copy link

I have the same issue, the only solution I have found is to use the esp_log_write to redirect the message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

4 participants