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
elog_buf_output()函数有问题,输出不完整 `void elog_buf_output(const char *log, size_t size) { size_t write_size = 0, write_index = 0;
if (!is_enabled) { elog_port_output(log, size); return; }
//循环有什么用?每次调用此处只会被执行一次 while (true) { if (buf_write_size + size > ELOG_BUF_OUTPUT_BUF_SIZE) { //缓冲区满时log被拆分输出? write_size = ELOG_BUF_OUTPUT_BUF_SIZE - buf_write_size; memcpy(log_buf + buf_write_size, log + write_index, write_size); //write_index不是静态局部变量,此处有意义? write_index += write_size; size -= write_size; buf_write_size += write_size; /* output log / elog_port_output(log_buf, buf_write_size); / reset write index */ buf_write_size = 0; } else { memcpy(log_buf + buf_write_size, log + write_index, size); buf_write_size += size; break; } } }`
修改成以下代码后测试正常: `void elog_buf_output(const char *log, size_t size) { //未使能缓冲输出时直接输出 if (!is_enabled) { elog_port_output(log, size); return; } //缓冲区空间不足时先输出 if (buf_write_size + size > ELOG_BUF_OUTPUT_BUF_SIZE) { elog_port_output(log_buf, buf_write_size); buf_write_size = 0; } //日志拷贝至缓冲区 memcpy(log_buf + buf_write_size, log, size); buf_write_size += size;
}`
The text was updated successfully, but these errors were encountered:
buf 缓冲模式,基本没有被应用,有问题欢迎提交 pr
Sorry, something went wrong.
No branches or pull requests
elog_buf_output()函数有问题,输出不完整
`void elog_buf_output(const char *log, size_t size) {
size_t write_size = 0, write_index = 0;
//循环有什么用?每次调用此处只会被执行一次
while (true) {
if (buf_write_size + size > ELOG_BUF_OUTPUT_BUF_SIZE) {
//缓冲区满时log被拆分输出?
write_size = ELOG_BUF_OUTPUT_BUF_SIZE - buf_write_size;
memcpy(log_buf + buf_write_size, log + write_index, write_size);
//write_index不是静态局部变量,此处有意义?
write_index += write_size;
size -= write_size;
buf_write_size += write_size;
/* output log /
elog_port_output(log_buf, buf_write_size);
/ reset write index */
buf_write_size = 0;
} else {
memcpy(log_buf + buf_write_size, log + write_index, size);
buf_write_size += size;
break;
}
}
}`
修改成以下代码后测试正常:
`void elog_buf_output(const char *log, size_t size)
{
//未使能缓冲输出时直接输出
if (!is_enabled) {
elog_port_output(log, size);
return;
}
//缓冲区空间不足时先输出
if (buf_write_size + size > ELOG_BUF_OUTPUT_BUF_SIZE) {
elog_port_output(log_buf, buf_write_size);
buf_write_size = 0;
}
//日志拷贝至缓冲区
memcpy(log_buf + buf_write_size, log, size);
buf_write_size += size;
}`
The text was updated successfully, but these errors were encountered: