//--------------------------------------------------------------------------------- size_t MavESP8266Log::log(const char *format, ...) { va_list arg; va_start(arg, format); char temp[1024]; size_t len = ets_vsnprintf(temp, 1024, format, arg); #ifdef ENABLE_DEBUG Serial1.print(temp); #endif #if 0 //-- TODO if(_buffer) { for(int i = 0; i < len; i++) { _buffer[_log_write] = temp[i]; _log_write = (_log_write + 1) % _buffer_size; if (_log_read == _log_read) { _log_read = (_log_read + 1) % _buffer_size; _log_posistion++; } } } #endif va_end(arg); return len; }
int ICACHE_RAM_ATTR snprintf(char* buffer, size_t size, const char* format, ...) { int ret; va_list arglist; va_start(arglist, format); ret = ets_vsnprintf(buffer, size, format, arglist); va_end(arglist); return ret; }
size_t Print::printf(const char *format, ...) { va_list arg; va_start(arg, format); char temp[1460]; size_t len = ets_vsnprintf(temp, 1460, format, arg); len = print(temp); va_end(arg); return len; }
void CDebugServer::send(const char *szFormat, ...) { static char szTemp[512]; va_list args; __builtin_va_start(args, szFormat); ets_vsnprintf(szTemp, (sizeof(szTemp)/sizeof(szTemp[0])) -1, szFormat, args); __builtin_va_end(args); for (auto s : m_sSockets) s->send((const uint8_t *)szTemp, strlen(szTemp)); }
//send formatted output to transmit buffer and call sendtxbuffer, if ready (previous espconn_sent is completed) sint8 ICACHE_FLASH_ATTR espbuffsentprintf(serverConnData *conn, const char *format, ...) { uint16 len; va_list al; va_start(al, format); len = ets_vsnprintf(conn->txbuffer + conn->txbufferlen, MAX_TXBUFFER - conn->txbufferlen - 1, format, al); va_end(al); if (len <0) { return len; } conn->txbufferlen += len; if (conn->readytosend) return sendtxbuffer(conn); return ESPCONN_OK; }
void Con::printf(const char *fmt, ...){ int l; char buffer[255]; l=strlen(fmt); va_list ap; va_start(ap, fmt); ets_vsnprintf(buffer,255, fmt, ap); va_end(ap); if (curType&CON_SERIAL){ Serial.print(buffer); } if (this->curType&CON_TCP){ if (ConTcp.connected()){ ConTcp.print(buffer); } } }
void IROM SysLog(SysLogLevel level, const char* file, const char* function, const char * format, ...) { char *p; buffer[0] = 0; va_list args; va_start(args, format); if (GetMutex(&logMutex) == 0) { for (p = "$$$:"; *p != 0; p++) uart0WriteWait(*p); for (p = file; *p != 0; p++) uart0WriteWait(*p); for (p = "$$$"; *p != 0; p++) uart0WriteWait(*p); for (p = function; *p != 0; p++) uart0WriteWait(*p); // uart0WriteBytes(":",1); // uart0WriteBytes(function,strlen(function)); // os_printf_plus(" Syslog called by %s ",function); conflicts += 1000; va_end(args); return; } uint32_t time = SysMillis(); ets_vsnprintf(buffer, sizeof(buffer), format, args); va_end(args); char dst[40]; dst[0] = '\0'; strAlign(dst, 18, file, strlen(file)); strAlign(&dst[18], 18, function, strlen(function)); // if (level > LOG_INFO) { // put log in mqtt buffer // ets_sprintf(lastLog, "%s:%s:%s", SysLogLevelStr[level], dst, buffer); // } ets_snprintf(lastLog, sizeof(lastLog), "%10u | %s | %s\n", time, dst, buffer); uart0WriteBytes(lastLog, strlen(lastLog)); // os_delay_us(1000); ets_delay_us(10000); // os_printf_plus(); ReleaseMutex(&logMutex); }
static void ICACHE_FLASH_ATTR dmesg(const char *format, ...) { const size_t BUFFER_SIZE = 256; char *buffer = (char *)os_malloc(BUFFER_SIZE); if (!buffer) return; ; va_list args; va_start(args, format); int n = ets_vsnprintf(buffer, BUFFER_SIZE, format, args); va_end(args); if (n > 0 && n < BUFFER_SIZE) MQTT_Publish(&mqtt_client, TOPIC_DMESG, buffer, n, 0, 1); os_free(buffer); }
//--------------------------------------------------------------------------------- size_t MavESP8266Log::log(const char *format, ...) { va_list arg; va_start(arg, format); char temp[1024]; size_t len = ets_vsnprintf(temp, 1024, format, arg); #ifdef ENABLE_DEBUG Serial1.print(temp); #endif if(_buffer) { for(int i = 0; i < len; i++) { _buffer[_log_offset] = temp[i]; _log_offset = (_log_offset + 1) % _buffer_size; _log_position++; } } va_end(arg); return len; }
int ICACHE_RAM_ATTR vsnprintf(char * buffer, size_t size, const char * format, va_list arg) { return ets_vsnprintf(buffer, size, format, arg); }
/** * Create a SYSLOG message. Refer to RFC5424. * * This function has been adapted for use by this application and is not * intended to be a general purpose function. */ void ICACHE_FLASH_ATTR syslog(int msg_id, ...) { char *buffer; size_t new_buf_len; int written; int total_written; int space_left; int write_index = -1; sint16 rc; const SYSLOG_MSG *msg = &syslog_msgs[msg_id]; /** * Format is: * * - "<" Priority ">" * - Version <space> * - Timestamp <space> * - Hostname <space> * - Application name <space> * - Process ID <space> * - Msg ID <space> * - Structured-data <optional> * - Message. * * At this time, most info is being ignored. */ va_list argp; va_start(argp, msg_id); // CONSOLE("Debug: IN: Syslog: %d\n", msg_id); write_index = syslog_write_index(); buffer = syslog_stack[write_index]; space_left = SYSLOG_BUF_SIZE; total_written = 0; written = ets_snprintf(buffer, space_left, "<%d>%d %s %s %s %d %d", (msg->prival | LOG_LOCAL0), SYSLOG_VERSION, sntp_get_syslog_time(), syslog_ip_address, syslog_app_name, msg->proc_id, msg_id); space_left -= written; total_written += written; #ifndef SYSLOG_STRUCTURED_IN_MSG if (msg->parms != NULL) { written = ets_snprintf( &buffer[total_written], space_left, " [%s ", syslog_app_name); space_left -=written; total_written += written; written = ets_vsnprintf( &buffer[total_written], space_left, msg->parms, argp); space_left -=written; total_written += written; written = ets_snprintf(&buffer[total_written], space_left, "]"); space_left -=written; total_written += written; } else #endif { // NILLVALUE (lone '-') written = ets_snprintf(&buffer[total_written], space_left, " -"); space_left -=written; total_written += written; } if (msg->msg != NULL) { written = ets_snprintf( &buffer[total_written], space_left, " "); space_left -=written; total_written += written; written = ets_snprintf( &buffer[total_written], space_left, msg->msg); space_left -=written; total_written += written; } #ifdef SYSLOG_STRUCTURED_IN_MSG /** * Append any structured data as part of the message. */ if (msg->parms != NULL) { written = ets_snprintf( &buffer[total_written], space_left, " [%s ", syslog_app_name); space_left -=written; total_written += written; written = ets_vsnprintf( &buffer[total_written], space_left, msg->parms, argp); space_left -=written; total_written += written; written = ets_snprintf(&buffer[total_written], space_left, "]"); space_left -=written; total_written += written; } #endif syslog_length[write_index] = total_written; CONSOLE(buffer); // CONSOLE("Debug: MID: Syslog: %d\n", msg_id); syslog_sendto(); // CONSOLE("Debug: OUT: Syslog: %d\n", msg_id); va_end(argp); }
int vsnprintf(char * buffer, size_t size, const char * format, va_list arg) { return ets_vsnprintf(buffer, size, format, arg); }