How to use wxLogWindow?

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
rayam
Earned a small fee
Earned a small fee
Posts: 13
Joined: Tue Mar 08, 2005 7:12 am

How to use wxLogWindow?

Post by rayam »

I make it but unable close it by calling the delete method inside wxApp::OnExit() or wxFrame::OnClose();. What is the suitable way to use wxLogWindow? Or where are an example about it? Thank you.
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

As far as I know, wxLogWindow should not be shown directly, but instead you should use:

wxLogMessage, wxLogError, wxLogWarning shows the wxLogWindow when something needs to be displayed.

You can define a wxLogNull object on the stack to supress the log errors.

A pretty solid and good mechanism, it also shows the time and you can export the errors.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
gunnar
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Oct 13, 2004 11:27 am

Post by gunnar »

make it but unable close it by calling the delete method inside wxApp::OnExit() or wxFrame::OnClose();.
I have problems to understand what your problem is. If the log window is a child of your frame, it will be closed if your frame will be closed, whithout any work for you.


@Jorg
wxLogMessage, wxLogError, wxLogWarning shows the wxLogWindow when something needs to be displayed.
Is this really true? I think you need to explicitly Show() the log window. If a user closes it it stays closed. For that reason if have derived my own log window, which shows itself every time a message appears.
regards,
gunnar
Get the music out of wxWidgets, use wxMusik ;-)
from http://musik.berlios.de
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

I never need to show the log error message window explicitly. That is part of the power of logging I assume it is all done for you.

Multiple wxLogError calls will appear in the same window, with timestamps. The last time I used it with wxLexer (class under development) and I would get an error from my class, the log window pops up right away.

This was 2.5.3 I am not sure if anything has changed since this ...

Regards,
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
ConnorMacLeod
Knows some wx things
Knows some wx things
Posts: 39
Joined: Thu Nov 25, 2004 10:10 am
Location: Germany

Post by ConnorMacLeod »

I always use wxLogDebug which places debug output in my IDE/console outputwindow.
[wxMSW 2.6.1/VC7.1 .NET 2003/WinXP]
armink
Experienced Solver
Experienced Solver
Posts: 79
Joined: Tue Aug 31, 2004 10:25 am
Location: Bavaria / Germany

Post by armink »

In a Frames constructor I have

Code: Select all

MyFrame::MyFrame( ...){

...
m_log_textctrl =
	    new wxTextCtrl (this, -1, wxEmptyString, wxPoint (0, 250),
			    wxSize (700, 100), wxTE_MULTILINE);

  m_logger = new wxLogTextCtrl (m_log_textctrl);
  m_logger->SetActiveTarget (m_logger);
...
}
Now u can use e.g. wxLogMessage() everywhere in your Application, it s output will be written to the above wxTextCtrl ...
Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg »

The only thing i would still like, is to embed the wxLogWindow's list view (with time stamp and icons) inside my own app, that would be great.. But other then that, the wxLog mechanism is excellent. :-)

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
hmtksteve
Earned a small fee
Earned a small fee
Posts: 10
Joined: Fri Mar 25, 2005 2:35 am

Wny not

Post by hmtksteve »

Why not just create a class of wxframe with a read only text control and just send it mesages? That's what I do...
Post Reply