C++ 用于限制半常量日志消息的日志保护程序
我正在我的应用程序中使用boostlog进行日志记录 然而,在我的代码的某些部分中,我有一些日志语句,如果出现问题,这些语句可能会经常出现。我想要一种能够在检测到相同日志消息不断出现时限制日志消息的防护 e、 g.(这是一个简化的示例,不是实际实现)C++ 用于限制半常量日志消息的日志保护程序,c++,logging,boost,C++,Logging,Boost,我正在我的应用程序中使用boostlog进行日志记录 然而,在我的代码的某些部分中,我有一些日志语句,如果出现问题,这些语句可能会经常出现。我想要一种能够在检测到相同日志消息不断出现时限制日志消息的防护 e、 g.(这是一个简化的示例,不是实际实现) while(!framebuffer.try_pop(frame)) { BOOST_LOG(trace)简单一点怎么样,如果您想: int tooMany = 10; int count = 0; while(!framebuffer.try_p
while(!framebuffer.try_pop(frame))
{
BOOST_LOG(trace)简单一点怎么样,如果您想:
int tooMany = 10;
int count = 0;
while(!framebuffer.try_pop(frame))
{
if(count < tooMany) {
BOOST_LOG(trace) << "Buffer underrun.";
}
count++;
}
if(count >= tooMany) {
BOOST_LOG(trace) << "Message repeated: " << count << " times.";
}
int-tooMany=10;
整数计数=0;
而(!framebuffer.try_pop(frame))
{
如果(计数<太多){
BOOST_LOG(trace)=太多){
BOOST_日志(跟踪)
int tooMany = 10;
int count = 0;
while(!framebuffer.try_pop(frame))
{
if(count < tooMany) {
BOOST_LOG(trace) << "Buffer underrun.";
}
count++;
}
if(count >= tooMany) {
BOOST_LOG(trace) << "Message repeated: " << count << " times.";
}