const
BreakingLine = '||----------------------------------------------------------------------------||';
procedure CreateLogfile;
var
T:TextFile;
FN:String;
begin
FN := ChangeFileExt(Application.Exename, '.log');
AssignFile(T, FN);
Rewrite(T);
Append(T);
WriteLn(T, BreakingLine);
WriteLn(T, ' Logfile ini dibentuk pada: ' + DateToStr(Now));
WriteLn(T, BreakingLine);
WriteLn(T, '');
CloseFile(T);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
aLogMessage:String;
T:TextFile;
FN:String;
begin
if ((edit1.Text='Admin') and (edit2.Text='admin')) then
begin
FN := ChangeFileExt(Application.Exename, '.log');
if (not FileExists(FN)) then
begin
CreateLogFile;
end;
AssignFile(T, FN);
Append(T);
WriteLn(T, 'LOG IN SUKSES -> User "'+ edit1.Text+ '" masuk pada '+ DateTimeToStr(Now));
CloseFile(T);
showmessage('Anda berhasil login.');
end
else
begin
FN := ChangeFileExt(Application.Exename, '.log');
if (not FileExists(FN)) then
begin
CreateLogFile;
end;
AssignFile(T, FN);
Append(T);
WriteLn(T, 'LOG IN GAGAL -> User "'+ edit1.Text+ '" mencoba masuk pada '+ DateTimeToStr(Now));
CloseFile(T);
showmessage('Anda gagal login.');
end;
end;
Random post
Saturday, February 3, 2018
√ Menciptakan Log File Di Delphi
Penulis hiyahiya
Diterbitkan February 03, 2018