We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
测试环境为
#define LOG_BUFFER_SIZE (53-6) /**< log输出缓冲大小 connect(&m_timer,&QTimer::timeout,this,&MainUI::on_timeout); m_timer.start(10); void MainUI::on_timeout() { shell_log_task(); logError("2023年4月14日15:25:23"); }
建议修改为,完美解决,已测试
void logWrite(Log *log, LogLevel level, const char *fmt, ...) { va_list vargs; int len; #if LOG_USING_LOCK == 1 logLock(log); #endif /* LOG_USING_LOCK == 1 */ va_start(vargs, fmt); len = vsnprintf(logBuffer, LOG_BUFFER_SIZE, fmt, vargs); va_end(vargs); if(len >= LOG_BUFFER_SIZE - 1 || len < 0) { logBuffer[LOG_BUFFER_SIZE -1] = 0; logBuffer[LOG_BUFFER_SIZE -2] ='\n'; logBuffer[LOG_BUFFER_SIZE -3] = '\r'; logWriteBuffer(log, level, logBuffer, LOG_BUFFER_SIZE - 1); } else { logWriteBuffer(log, level, logBuffer, len); } #if LOG_USING_LOCK == 1 logUnlock(log); #endif /* LOG_USING_LOCK == 1 */ }
The text was updated successfully, but these errors were encountered:
对 vsnprintf 的使用确实有问题,感谢指正
vsnprintf
Sorry, something went wrong.
No branches or pull requests
测试环境为
建议修改为,完美解决,已测试
The text was updated successfully, but these errors were encountered: