function Log_write(fname, text:string):string;
var f:TStringList;
begin
if not DirectoryExists('logs') then CreateDir('logs');
f:=TStringList.Create;
try
if FileExists('logs\'+fname+'.log') then
f.LoadFromFile('logs\'+fname+'.log');
f.Insert(0,DateTimeToStr(Now)+chr(9)+text);
while f.Count>1000 do f.Delete(1001);
f.SaveToFile('logs\'+fname+'.log');
finally
f.Destroy;
end;
end;