[wxWidgets 3.1.1, Windows 7 64 bit]
Hello all,
in wx documentation I read, that wxCmdLineParser.Parse() can generate messages, that "go to standard wx logging system". That seems not to be true. I defined a new wxLogStream() target at wxApp start. All other messages go there, but not that from wxCmdLineParser().
So it blocks the app and waits for pressing OK.
How to avoid that?
wxCmdLineParser, redirect output Topic is solved
wxCmdLineParser, redirect output
Best regards
Gnawer
Gnawer
Re: wxCmdLineParser, redirect output
Cursory source search shows that wxCmdLineParser uses wxMessageOutput for the output.
My guess would be you unfortunately need to take care of it yourself, overriding wxMessageOutput. Testing whethe it works as expected should be really quick though...
My guess would be you unfortunately need to take care of it yourself, overriding wxMessageOutput. Testing whethe it works as expected should be really quick though...
Re: wxCmdLineParser, redirect output
So, finally, I solved it.
The solution is to use an undocumented class wxMessageOutputLog.
To redirect all outputs (not only from wxCmdLineParser) to the log target, specify this in your application (for example in MyApp::OnInit()).
To restore previous state use this.
Issues detected in wx docu:
The solution is to use an undocumented class wxMessageOutputLog.
To redirect all outputs (not only from wxCmdLineParser) to the log target, specify this in your application (for example in MyApp::OnInit()).
Code: Select all
auto oldMsgOutput = wxMessageOutput::Get();
auto newMsgOutput = new wxMessageOutputLog();
wxMessageOutput::Set(newMsgOutput);
Code: Select all
wxMessageOutput::Set(oldMsgOutput);
delete newMsgOutput;
- - information that wxCmdLineParser::Parse() prints usage to wx standard logging system, is wrong.
- class wxMessageOutputLog is not documented.
Best regards
Gnawer
Gnawer
Re: wxCmdLineParser, redirect output
wxMessageOutput is a actually a part of the official logging system. I have no idea why it is used there, as opposed to the usual wxLog* functions.Gnawer wrote:Issues detected in wx docu:
- - information that wxCmdLineParser::Parse() prints usage to wx standard logging system, is wrong.
- class wxMessageOutputLog is not documented.
wxWidgets have many undocumented classes and they are usually undocumented for a reason.
In any way, you need to report the issue(s) on the wxTrac instead of here.
Re: wxCmdLineParser, redirect output
What was the purpose of all this anyway? Did you just want to suppress the message?
That can also be accomplished by overriding wxApp::OnInitCmdLine and wxApp::OnCmdLineParsed
That can also be accomplished by overriding wxApp::OnInitCmdLine and wxApp::OnCmdLineParsed
Use the source, Luke!