Using esp_log_set_vprintf() function
Posted: Sat Dec 16, 2017 8:09 am
Hi I am trying to do Remote Logging for the esp32 .
I have implemented a function to convert the LOG data to the string which I will be sending over the Network .
The problem I am stuck here is to use the esp_log_set_vprintf() ??
DO you have any example or what for the above ??
I have implemented a function to convert the LOG data to the string which I will be sending over the Network .
The problem I am stuck here is to use the esp_log_set_vprintf() ??
DO you have any example or what for the above ??
Code: Select all
void LOG_TO_STRING(const char *format,...)
{
ESP_LOGI("NO TAG","Call Accepted ");
char *string;//printf result will be sotred in this
va_list arguments_list;
va_start(arguments_list,format);//Initialiasing the List
//Calculating & Allocating Size
size_t size_string=snprintf(NULL,0,format,arguments_list);//Calculating the size of the formed string
string=(char *)malloc(size_string+4);//Initialising the string
vsnprintf(string,size_string,format,arguments_list);//Storing the outptut into the string
va_end(arguments_list);//Deinitializing the List
ESP_LOGI("NO TAG","Converted String is : %s",string);
free(string);
}