2012-06-14 42 views
1

我正在使用pantheios庫進行日誌記錄。我有:Pantheios在C++中設置顯示級別

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

,其輸出:
[MyApplication的6月14 15:45:26.549;調試]:我調試
[MyApplication.1,Jun 14 15:45:26.549;信息]:一些信息

但我想顯示的信息和調試之間進行選擇:

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

,輸出:
[MyApplication.1,15年6月14日:45:26.549;信息]:一些信息

+0

http://dinhngocson.blogspot.com/2010/11/pantheios-logging-library-basic.html – 2012-06-14 13:35:23

回答

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

你應該參考thisthis example瞭解更多信息。

+0

更新的驗證。你能再看一遍嗎? – user1307957

+0

我已經更新了我的答案。 –

+0

給我多重定義錯誤使用pantheios.1.fe.simple.gcc46(也與pantheios.1.fe.all.gcc46) – user1307957