home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softwarová Záchrana 3
/
Softwarova-zachrana-3.bin
/
StartRight
/
source.zip
/
UnitErrorLog.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2002-10-26
|
990b
|
51 lines
unit UnitErrorLog;
{
Purpose:
Just read the Unit's name - it says it all.
}
interface
type TErrorLog = class(TObject)
public
procedure Add(s : string); overload;
procedure Add(err : cardinal; s : string); overload;
end;
var ErrorLog : TErrorLog;
implementation
uses SysUtils, Forms {for Applicaiton object};
var filename : string;
procedure TErrorLog.Add(s : string);
var f : textfile;
begin
assignfile(f, filename);
if FileExists(filename) then begin
append(f);
end else begin
rewrite(f);
end;
writeln(f, DateTimeToStr(now) + ' ' + s);
close(f);
end;
procedure TErrorLog.Add(err : cardinal; s : string);
begin
s := IntToStr(err) + ' : ' + SysErrorMessage(err) + ' (' + s + ')';
self.Add(s);
end;
begin
ErrorLog := TErrorLog.Create();
filename := IncludeTrailingPathDelimiter( ExtractFilePath( Application.EXEName ) ) + 'error.txt';
end.