1
我无法更改wxLog功能的LogLevel。更改wxWidgets LogLevel
我想达到什么目的:将所有内容记录到日志文件中。
在下面的示例代码日志记录基本上可行,但我只看到LogLevel为Warning
或Error
的消息。我认为使用wxLog::SetLogLevel(wxLOG_Info);
来设置logLevel应该够了,但显然我错过了一些东西。任何提示?
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <wx/stdpaths.h>
class TestApp : public wxApp
{
public:
virtual bool OnInit();
private:
FILE* m_pLogFile;
};
bool TestApp::OnInit()
{
m_pLogFile = fopen("c:\\tmp\\foo.txt", "a+");
if (m_pLogFile == NULL)
{
return false;
}
wxLogStderr* pFileLogger = new wxLogStderr(m_pLogFile);
delete wxLog::SetActiveTarget(pFileLogger);
wxLog::SetLogLevel(wxLOG_Info);
wxLogError(L"Error");
wxLogWarning(L"Warning");
wxLogInfo(L"Info");
wxLogVerbose(L"Verbose");
wxLogDebug(L"Debug");
wxFrame* pFrame = new wxFrame(NULL, wxID_ANY, L"Title");
pFrame->Show();
return true;
}
wxIMPLEMENT_APP(TestApp);
另请参阅[此提交](https://github.com/wxWidgets/wxWidgets/commit/da7388c9c8f875c4136b79c547e7663fe9bc41f7) –