Skip to content

同步写日志的功能 #4

Answered by pippocao
sdaereew asked this question in Q&A
Discussion options

You must be logged in to vote

不用担心,不管是同步日志还是异步日志,在你从日志函数返回的时候,所有参数的数据就都已经被拷贝到内部的ring_buffer上了,外面的就随便被回收了。你只要保证在你的error函数执行期间,这个数据没有被回收或者被其他线程修改就行。

另外,最好不要把char[]转成std::string,这里会生成一次堆上内存分配,直接转char*(如果有\0结尾)或者直接传入char[]就好

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by pippocao
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3 on August 13, 2024 14:37.