gpt4 book ai didi

c++ - Pantheios 在 C++ 中设置显示级别

转载 作者:行者123 更新时间:2023-11-30 01:26:07 26 4
gpt4 key购买 nike

我正在使用 Pantheios 库进行日志记录。我有:

pantheios::log(pantheios::debug, "I'm debug");
pantheios::log(pantheios::informational, "Some info");

哪些输出:

[MyApplication, Jun 14 15:45:26.549; Debug] : I'm debug
[MyApplication.1, Jun 14 15:45:26.549; Informational] : Some info

但我想在显示信息和调试之间进行选择:

 set_level(pantheios::informational) //what should this be ?
pantheios::log(pantheios::debug, "I'm debug");
pantheios::log(pantheios::informational, "Some info");

哪些输出:

[MyApplication.1, Jun 14 15:45:26.549; Informational] : Some info

最佳答案

实际过滤日志级别的“正确”方法是自定义记录器前端并覆盖 pantheios::pantheios_fe_isSevereityLogged(),如下所示:

namespace
{
static int s_log_level = pantheios::debug;
}

PANTHEIOS_CALL(int) pantheios_fe_isSeverityLogged(void *token,
int severity, int backEndId)
{
return severity <= s_log_level;
}

你应该引用thisthis example获取更多信息。

关于c++ - Pantheios 在 C++ 中设置显示级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11034238/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com