I have a form program in Delphi. I've made a log for different actions in the program. I'm pretty sure I need to save it in rtf file with different colors depending on the line I'm entering but don't know how to change the color. I'm also opening the file with richedit, so I can see the different colors when done.
This is the procedure I use to enter the lines previously inserted in a stringlist(logText), whenever I want the actions added to the log file(logfil). Usually I do it when there's a new login and when a session of an account is ended. At the moment I use .txt file but I'm pretty sure I need rtf?
procedure AddToLogFile();
var
i : integer;
begin
with frmMain do
begin
i := 0;
AssignFile(logFile, 'C:\Users\lyuben\Desktop\Lyuben Airport Delphi\Log File\LogFile.txt');
Append(logFile);
while i < logText.Count do
begin
Writeln(logFile, logText.Strings[i]);
i := i + 1;
end;
CloseFile(logFile);
end;
end;
This is how I add text to the stringlist(logText)
dateTimeNow := Now;
logText.Add('<' + DateTimeToStr(dateTimeNow) + '> A new flight was added');
And this is how I call the procedure LogFileUse.AddToLogFile;