我正在使用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以获得更多信息。

09-06 13:54