写日志函数AppLog(记录程序中的错误或操作流程) Delphi

procedure AppLog(msg: string); 
var
f: textfile;
begin
try
try
AssignFile(f, ExtractFilePath(ParamStr(0)) + 'app.log');
if not fileexists(ExtractFilePath(ParamStr(0)) + 'app.log') then
rewrite(f)
else
append(f);
writeln(f, FormatDateTime('yyyy-MM-dd HH:mm:ss', Now()) + ' ' + msg);
finally
try
closefile(f);
except
end;
end;
except

end;
end;
posted @ 2011-12-31 23:41  世界之窗  阅读(252)  评论(0)    收藏  举报