Disabling message boxes for wxLogVerbose

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
tonto
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Oct 29, 2010 12:47 am

Disabling message boxes for wxLogVerbose

Post by tonto » Sun Dec 15, 2013 3:52 am

Hi all,
I'm trying to setup a log system with wxLogStream and wxLogGui enabled
I would like to have the functionality of wxLogGui (message boxes for wxLogMessage,wxLogWarning,wxLogError, and status bar for wxLogStatus) but i would also like to output more detailed information to the file (with wxLogVerbose).

One possibility i thought was to use wxLog::SetVerbose(), but since it is a static function, I cant just apply it to just one wxLog* instance (i.e. both wxLogGui and wxLogStream now have verbose) and as a result i get message boxes from the wxLogGui for verbose outputs

Any ideas for a solution? We could
Thanks!


Here's an example of my setup code for the logs

Code: Select all

	wxLog::SetLogLevel(wxLOG_Max);
	wxLog::SetVerbose();
	wxFFile *test=new wxFFile("test.log","a");
	wxLog *temp=new wxLogStderr(test->fp());
	wxLog::SetActiveTarget(temp);

	wxLog::SetActiveTarget(new wxLogChain(new wxLogGui()));
	

tonto
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Oct 29, 2010 12:47 am

Re: Disabling message boxes for wxLogVerbose

Post by tonto » Sun Dec 15, 2013 11:55 pm

I started saying it in my original post but i think I could subclass wxLogGui. Are there any examples of that?

tonto
In need of some credit
In need of some credit
Posts: 6
Joined: Fri Oct 29, 2010 12:47 am

Re: Disabling message boxes for wxLogVerbose

Post by tonto » Tue Jan 21, 2014 8:01 am

Hey all,
I had a solution that i think works using this code to make all the various wxlog instances work together

Here, i subclasses the wxLogGui to ignore the verbose messages

Code: Select all

class wxLogGuiMod :public wxLogGui {
	protected:
	virtual void DoLogRecord(wxLogLevel level,
                             const wxString& msg,
                             const wxLogRecordInfo& info);
};
void wxLogGuiMod::DoLogRecord(wxLogLevel level,
                             const wxString& msg,
                             const wxLogRecordInfo& info)
{
	if(level==wxLOG_Info ) return;
	else wxLogGui::DoLogRecord(level,msg,info);
}
Then you can initialize various instances together like this. Note the order of initializing things matters, and you can with this get a logfile wxLogStdErr, a logwindow wxLogWindow, and messageboxes and status bar features of wxLogGui

Code: Select all

	wxLog::SetLogLevel(wxLOG_Max);
	wxLog::SetVerbose();
	//create logfile
	wxFFile *test=new wxFFile("yourLogFile.log","a");
	wxLog *temp=new wxLogStderr(test->fp());
	wxLog::SetActiveTarget(temp);
	//create loggui and chain it
	wxLog::SetActiveTarget(new wxLogChain(new wxLogGuiMod()));
	//create logwindow
	new wxLogWindow(this, wxS("Log messages"),true);//true to make visible at start
	//no need to setactivetarget or wxlogchain on wxLogWindow

Post Reply