Delphi实用小function

Write Log

    // strLog : the log content need write to log file;
    // strFile: the compliete file path(include the file name) of the log file. e.g. C:log.log;
    procedure WriteLog(strLog, strFile: string);
    var
       fLog: TextFile;
    begin
       AssignFile(fLog, strFile);
       try
          if FileExists(strFile) then
            Append(fLog)
         else
            Rewrite(fLog);
    
         //ready to write log content
         Writeln(fLog,Format('%s -> %s', [FormatDateTime('hh:mm:ss',now()), strLog]) );
      finally
         CloseFile(fLog);
      end;
   end;
原文地址:https://www.cnblogs.com/larson/p/3423609.html