home *** CD-ROM | disk | FTP | other *** search
/ Softwarová Záchrana 3 / Softwarova-zachrana-3.bin / StartRight / source.zip / UnitErrorLog.pas < prev    next >
Pascal/Delphi Source File  |  2002-10-26  |  990b  |  51 lines

  1. unit UnitErrorLog;
  2. {
  3.     Purpose:
  4.         Just read the Unit's name - it says it all.
  5. }
  6. interface
  7.  
  8. type TErrorLog = class(TObject)
  9.     public
  10.         procedure Add(s : string); overload;
  11.         procedure Add(err : cardinal; s : string); overload;
  12. end;
  13.  
  14.  
  15. var ErrorLog : TErrorLog;
  16.  
  17. implementation
  18.  
  19. uses SysUtils, Forms {for Applicaiton object};
  20.  
  21.  
  22. var filename : string;
  23.  
  24. procedure TErrorLog.Add(s : string);
  25. var f : textfile;
  26. begin
  27.     assignfile(f, filename);
  28.     if FileExists(filename) then begin
  29.         append(f);
  30.     end else begin
  31.         rewrite(f);
  32.     end;
  33.     writeln(f, DateTimeToStr(now) + ' ' + s);
  34.     close(f);
  35. end;
  36.  
  37. procedure TErrorLog.Add(err : cardinal; s : string);
  38. begin
  39.     s := IntToStr(err) + ' : ' + SysErrorMessage(err) + ' (' + s + ')';
  40.     self.Add(s);
  41. end;
  42.  
  43.  
  44.  
  45. begin
  46.     ErrorLog := TErrorLog.Create();
  47.     filename := IncludeTrailingPathDelimiter( ExtractFilePath( Application.EXEName ) ) + 'error.txt';
  48.  
  49.  
  50. end.
  51.