Hi all,

I have a bit of a weird problem,
i have a basic debugger unit that i use with my games engine, it works fine but when ever i turn the debugger off it causes a general exception, but works fine when it is on.

The debugger is just a Stringlist with functions to write to it.

Debugger unit:
[pascal]
uses
Classes;

var
Log: TStringList;
LogFilename: String;
LogInitialized: Boolean = False;

..

procedure IintializeLog(const Filename: String);
begin
LogFilename := Filename;
Log := TStringList.Create;
If FileExists(LogFilename) Then DeleteFile(LogFilename);
LogInitialized := True;
LogDetails;
end;

procedure OpenLog;
begin
If Not LogInitialized Then Exit;
If FileExists(LogFilename) Then Log.LoadFromFile(LogFilename);
end;

procedure CloseLog;
begin
If Not LogInitialized Then Exit;
Log.SaveToFile(LogFilename);
end;

procedure WriteToLog(const Value: String);
begin
If Not LogInitialized Then Exit;
OpenLog;
Log.Add(Value);
CloseLog;
end;

procedure LogDetails;
begin
WriteToLog('Log version **** ');
end;
[/pascal]

When my engine starts it calls InitializeLog if i want the debugger enabled (which runs ok) but if i dont then i get the exception!

Maybe i have missed something but i can not see anything wrong with it :s

If any one can help it would be great