procedure WriteLog(sAppPath: string; sContent: string; logNamePre: string = ''; logDir: string = 'log');
var
tFile: TextFile;
filename: string;
begin
filename := sAppPath + logDir + '\' + logNamePre + FormatDateTime('yyyyMMdd', Now) + '.txt';
if not DirectoryExists(sAppPath + logDir) then
begin
MkDir(sAppPath + logDir);
end;
AssignFile(tFile, filename);
if FileExists(filename) then
Append(tFile)
else
Rewrite(tFile);
Writeln(tFile, sContent + ' ' + FormatDateTime('yyyy-MM-dd hh:nn:ss', Now));
CloseFile(tFile);
end;
Delphi写日志函数
最新推荐文章于 2023-10-05 06:08:42 发布