Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 用于限制半常量日志消息的日志保护程序_C++_Logging_Boost - Fatal编程技术网

C++ 用于限制半常量日志消息的日志保护程序

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

我正在我的应用程序中使用boostlog进行日志记录

然而,在我的代码的某些部分中,我有一些日志语句,如果出现问题,这些语句可能会经常出现。我想要一种能够在检测到相同日志消息不断出现时限制日志消息的防护

e、 g.(这是一个简化的示例,不是实际实现)

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.";
}