标签:
//日志 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;
标签:
原文地址:http://my.oschina.net/shanei5107/blog/500502