ZLMediaKit / ZLToolKit

一个基于C++11的轻量级网络框架,基于线程池技术可以实现大并发网络IO
MIT License
1.94k stars 581 forks source link

When multiple threads print to the same log, due to log optimization, the written log may be incorrect. #209

Closed cwl2914 closed 7 months ago

cwl2914 commented 8 months ago

Log writing function: writeChannels optimizes for duplicate logs. If multiple threads print the same log, it will accumulate the number of repetitions. When the log is different, it will print the duplicate log, but the printed log is the first one when it is duplicated (the thread name printed is the thread corresponding to the first log), it is possible that the subsequent duplicate logs are not from the thread corresponding to the first one, it is recommended to add the thread condition when judging the duplication.

写日志函数:writeChannels会对重复日志做优化,如果多个线程打印同一个日志,会累记重复次数,等日志不一样时,会把重复的这条日志打印出来, 但是打印出来的日志是重复时最开始的那条(打印出来的线程名是第一条日志对应的线程), 可能后面重复的日志不是第一条对应的线程的, 建议判断重复的时候加上线程这个条件

TRANS_BY_GITHUB_AI_ASSISTANT

xiongguangjie commented 8 months ago

You can submit a PR in ZLToolKit.

你可以在ZLToolKit 提交PR

TRANS_BY_GITHUB_AI_ASSISTANT