//日志 function Log(AStr: string): boolean; var DateStr: string; MyTextFile: TextFile; FileName: string; begin Result := False; DateTimeToString(DateStr, ‘YYYY-MM-DD HH:MM:SS‘, Now); AStr := DateStr + ‘ ‘+ AStr; DateTimeToString(DateStr, ‘YYYYMMDD‘, Now); FileName := ‘.\Log\‘ + DateStr + ‘.Log‘; if not FileExists(FileName) then begin AssignFile(MyTextFile, FileName); Rewrite(MyTextFile); Try WriteLn(MyTextFile, ‘时间 消息‘); WriteLn(MyTextFile, AStr); Result := True; Exit; finally CloseFile(MyTextFile); end; end; AssignFile(MyTextFile, FileName); Append(MyTextFile); try WriteLn(MyTextFile, AStr); Flush(MyTextFile); Result := True; Exit; finally CloseFile(MyTextFile); end; end;
时间: 2024-10-09 09:26:46