Redirecting some messages to wxLogGui

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Redirecting some messages to wxLogGui

Gunter Königsmann
Dear all,

Sorry that I have to ask such a basic question but this time google doesn't seem to help me:
In my application I use wxLog::SetActiveTarget() in order to redirect all debug messages to an wxLogTextCtrl. Which works fine. But for errors (but not for all debug messages) during loading and saving a file I want to use wxLogGui instead. Is it possible to redirect log messages above a certain criticality level to wxLogGui whilst still receiving all debug messages in the wxLogTextCtrl?

If that isn't the case I will remove all debug messages from the load and save process and use wxLog::SetActiveTarget() before and after file operations.

Thanks in advance,
 Gunter.

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re: Redirecting some messages to wxLogGui

Vadim Zeitlin-4
On Thu, 1 Nov 2018 01:13:55 -0700 (PDT) Gunter Königsmann wrote:

GK> Sorry that I have to ask such a basic question but this time google
GK> doesn't seem to help me: In my application I use
GK> wxLog::SetActiveTarget() in order to redirect all debug messages to an
GK> wxLogTextCtrl. Which works fine. But for errors (but not for all debug
GK> messages) during loading and saving a file I want to use wxLogGui
GK> instead. Is it possible to redirect log messages above a certain
GK> criticality level to wxLogGui whilst still receiving all debug messages
GK> in the wxLogTextCtrl?

 The simplest way to do this is to just use wxLogChain which passes all
messages to the previously active log target when you create it, so if you
instantiate it with wxLogTextCtrl as ctor argument, it will log into it but
will also pass everything to the default wxLogGui, which happens to ignore
(i.e. not show to the user, even though they still go to e.g. debug output
under MSW) debug messages.

 If you want to have finer control than that, e.g. if you really only want
to show warnings and errors in wxLogGui but only send informational
messages to the text control, then you will need to derive your own log
target class similar to wxLogChain (you could inherit it from wxLogChain
too but I think it doesn't really help that much) and override the virtual
DoLogRecord() method in it. In this method you have access to the log level
of the message being logged and can decide whether you forward it to one
logger or both.

 Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Redirecting some messages to wxLogGui

Gunter Königsmann
Thanks a lot! That was exactly what I was searching for.

Kind regards,

  Gunter.

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re: Redirecting some messages to wxLogGui

Gunter Königsmann
One last question: If my application is GPL'ed and I want to use a modified version of the wxLogChain class - does the wxWindows license allow me to do this? As wxLogChain::DoLogRecord isn't virtual I cannot just derive from the class and override the method.

Thanks in advance,
and

Kind regards,
 Gunter.

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|

Re[2]: Redirecting some messages to wxLogGui

Vadim Zeitlin-4
On Sun, 18 Nov 2018 02:34:28 -0800 (PST) Gunter Königsmann wrote:

GK> One last question: If my application is GPL'ed and I want to use a
GK> modified version of the wxLogChain class - does the wxWindows license
GK> allow me to do this? As wxLogChain::DoLogRecord isn't virtual I cannot
GK> just derive from the class and override the method.

 wxWindows licence doesn't impose any constraints on your modifications,
i.e. you don't have to contribute them back (even though we encourage
people to do it) irrespectively of your own application licence. Of course,
with a GPL application, your changes are presumably available anyhow, so
it's even more of a non-issue in your case.

 This being said, wxLogChain::DoLogRecord() definitely _is_ virtual, so I'm
not sure why you can't just override this method in a derived class.

 Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment