Hello,
Serial.print with monitoring over usb was a good enough approach with a single prototype.
but with several deployed units, my ability to babysit them over USB/serial is somewhat tasking.
To avoid inventing the wheel, I would appreciate your advise on proper logging framework that can also be leveraged to send log information to a cloud. (I'm thinking about aws iot core with Mqtt)
Thank you in advance.
P.S. it would be nice to have logging to both serial and "cloud" without the need to constantly type 2 statements, checking for connection etc..
best practices- logging framework with cloud integration
-
- Posts: 22
- Joined: Mon Jul 22, 2019 2:29 pm
Re: best practices- logging framework with cloud integration
You could use esp_log_set_vprintf to set a custom vprintf function. This function could look like this :
Note that you would need a task to maintain the mqtt client connection.
Code: Select all
/*
* vprintf-like function to replace the logging output method
*/
int dual_vprintf(const char *fmt, va_list ap)
{
// 1. Log to a custom handler (could be a MQTT queue, UDP socket etc)
char str[256] = 0;
snprintf(str, 256, fmt, ap);
esp_mqtt_client_publish(client, "/topic/log", str, strlen(str), 0, 0);
//2. Still log to the standard output (UART)
return vprintf(fmt, ap);
}
Re: best practices- logging framework with cloud integration
agreed, and then i have to figure out some kind of buffer for logs and the log sending progress (over the connection).AloyseTech wrote: ↑Thu Jul 16, 2020 10:43 amYou could use esp_log_set_vprintf to set a custom vprintf function. This function could look like this :Note that you would need a task to maintain the mqtt client connection.Code: Select all
/* * vprintf-like function to replace the logging output method */ int dual_vprintf(const char *fmt, va_list ap) { // 1. Log to a custom handler (could be a MQTT queue, UDP socket etc) char str[256] = 0; snprintf(str, 256, fmt, ap); esp_mqtt_client_publish(client, "/topic/log", str, strlen(str), 0, 0); //2. Still log to the standard output (UART) return vprintf(fmt, ap); }
Who is online
Users browsing this forum: No registered users and 101 guests