Bug, perhaps?
BlitzMax Forums/BlitzMax Programming/Bug, perhaps?
| ||
[edit] Turns out I needed to force a flush stream...whoops. Hehe. Okay, I've got a Logger class that takes a string of data, decorates it, and writes it to a log file. In the following code, GErrorLog is a global instance of that logger, which is instantiated in it's own .bmx file which is imported with the import call at the top of the program. With the code below the call to GErrorLog.LogData() commented out (as in the codebox below), the logger works as intended and writes the line ""look, this better ******* work!" to the log file (note my slightly irritated tone :). However, when I uncomment the code below, the same call fails to work. I don't see how uncommenting the code below it could have any effect whatsoever on that line, but it does. Here's the code The ConnectionManager does indirectly access GErrorLog as well, but all of the ConnectionManager code is compiled either way (it's included in the TConnection_Framework.bmx file). Anyone have any ideas what might be causing this strange behavior? |
| ||
Okay, I did some more tests, commenting out small sections at a time to see what might be the culprit. This is just getting stranger. I commented out all of the code except for the While loop start and Wend, and nothing was written to the log. I then tried commenting out just the while start and end commands, leaving both calls to Listen() intact (well, all of my code actually), and IT WORKED! Just to be clear, this didn't work Strict Import "Framework_TConnection.bmx" GErrorLog.LogData( "look, this better ******* work!" ) rem Global ListeningManager:TListeningManager = TListeningManager.Create() Global ConnectionManager:TConnectionManager = New TConnectionManager ListeningManager.SetConnectionManager( ConnectionManager ) ListeningManager.AddPort( 30001 ) endrem While Not KeyHit( KEY_ESCAPE ) 'ListeningManager.Listen() 'ConnectionManager.Listen() Wend and this did work Strict Import "Framework_TConnection.bmx" GErrorLog.LogData( "look, this better ******* work!" ) Rem This is all commented out... Global ListeningManager:TListeningManager = TListeningManager.Create() Global ConnectionManager:TConnectionManager = New TConnectionManager ListeningManager.SetConnectionManager( ConnectionManager ) ListeningManager.AddPort( 30001 ) end rem 'While Not KeyHit( KEY_ESCAPE )----------commented out ListeningManager.Listen() ConnectionManager.Listen() 'Wend------------------commented out Somehow, the while loop itself is interfering with my loggers ability to write to a file? Uh...::scratches head:: |
| ||
Well, it's not a bug. Ends up that, for whatever reason, the stream was not being automatically flushed when the while loop was there. Forcing a flush fixed the problem. |