wxLog/wxLogTextCtrl SetTimeStamp

BlitzMax Forums/Brucey's Modules/wxLog/wxLogTextCtrl SetTimeStamp

plash(Posted 2009) [#1]
I'm baffled! I've looked at the wrapper code and everything.. it all looks OK, but when I try this (in MainFrame.OnInit):
		Method OnInit()
			
			Super.OnInit()
			
			Local log_textctrl:wxLogTextCtrl = New wxLogTextCtrl.Create(m_connectionlog)
			wxLog.SetActiveTarget(log_textctrl)
			DebugLog(wxLog.GetTimestamp())
			log_textctrl.SetTimestamp("[%I:%M:%S%P] ")
			DebugLog(wxLog.GetTimestamp())
			
			wxLogMessage("Log")
			wxLogError("Error")
			wxLogWarning("Warning")
			
		End Method


The log messages no longer have a timestamp (the debug message is "%X" and then ""), if I do not call SetTimeStamp, the messages have the default timestamp (which is "%X").

Any ideas?


Brucey(Posted 2009) [#2]
Okay. Fixed.
There were two issues... the first it was never actually setting the text... and the second, once I had sorted that out, after the string went out of scope it would revert to null... haw.

While I was fiddling around down there, I also implemented a type called wxLogStream.
This takes a TStream as a parameter, and allows you to log out to *any* writeable TStream ;-)
(may be handy for some of those hard to reach places).

(Yes, I realise that wxWidgets already has a wxLogStream class for logging to C++ streams, but I didn't think it likely anyone would have a C++ stream handle lying around to log to... and it seemed like a good name for the BlitzMax side).

Anyway... onto the next problem...


plash(Posted 2009) [#3]
Awesome, I was also looking for a way to log the messages to a file! Thanks.


plash(Posted 2009) [#4]
Is there any way to change the ": " that it inserts between the timestamp and the log message to something else?
In my opinion, the 'timestamp' should include the ": ", so that way we have more design options..


plash(Posted 2009) [#5]
I don't suppose it's possible to have two active targets? (a TextCtrl and a LogStream)

EDIT: Sorted this out.. probably should have looked at the code for LogStream a while ago.

Code (uses Brucey's appendable stream code):