1

我正在使用 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
4

1 回答 1

5

实际过滤日志级别的“正确”方法是自定义记录器前端和覆盖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;
}

您应该参考这个这个例子来获得更多信息。

于 2012-06-14T13:36:51.947 回答