home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 February / Chip_2004-02_cd1.bin / zkuste / konfig / download / msic / Help / Int / MiTeC_Journal.int < prev    next >
Text File  |  2003-10-10  |  4KB  |  98 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {         MiTeC System Information Component            }
  4. {                Journal Object                         }
  5. {           version 8.4 for Delphi 5,6,7                }
  6. {                                                       }
  7. {       Copyright ⌐ 1997,2003 Michal Mutl               }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. {$INCLUDE MITEC_DEF.INC}
  12.  
  13. unit MiTeC_Journal;
  14.  
  15. interface
  16.  
  17. uses Windows, Classes, SysUtils;
  18.  
  19. type
  20.   TEventLevel = (elStart, elSystem, elBegin, elEnd, elInformation, elWarning,
  21.                  elError, elData, elAction);
  22.  
  23.   TJournalRecord = record
  24.     Level: TEventLevel;
  25.     Timestamp: TDateTime;
  26.     TimestampStr: string;
  27.     Message: string;
  28.   end;
  29.  
  30.   TJournalBuffer = array of TJournalRecord;
  31.  
  32.   TJournal = class
  33.   private
  34.     FProcessHandle: THandle;
  35.     FFile: TFileStream;
  36.     FBuffer: TJournalBuffer;
  37.     FInternalSave: Boolean;
  38.     FFilename, FMachine, FUser: string;
  39.     FOverwrite: Boolean;
  40.     FStartTime,FStopTime: comp;
  41.     FInternalTime: array of Comp;
  42.     FModuleName: string;
  43.     FModuleVersion: string;
  44.     function GetRecord(Index: DWORD): TJournalRecord;
  45.     function GetRecordCount: DWORD;
  46.     procedure SetRecord(Index: DWORD; const Value: TJournalRecord);
  47.     procedure AddRecord(ATimestamp: TDateTime; AMessage: string; ALevel: TEventLevel); overload;
  48.     procedure AddRecord(ATimestamp: string; AMessage: string; ALevel: TEventLevel); overload;
  49.     procedure AddRecord(ARecord: TJournalRecord); overload;
  50.     procedure CreateFile;
  51.     procedure PushTime(Time: comp);
  52.     function PopTime: comp;
  53.   public
  54.     constructor Create(ADir,AFileNamePrefix: string; AInternalSave,AOverwrite,AReadOnly: boolean);
  55.     destructor Destroy; override;
  56.  
  57.     procedure WriteEvent(AMessage: string; ALevel: TEventLevel);
  58.     procedure WriteSpace;
  59.     procedure WriteEventFmt(const AFormat: string; const AArgs: array of const; ALevel: TEventLevel);
  60.     procedure LoadFromFile(AFilename: string);
  61.     procedure SaveToFile(AFilename: string);
  62.     procedure Clear;
  63.     procedure StartTimer;
  64.     function StopTimer: Comp;
  65.  
  66.     property FileName: string read FFilename;
  67.     property InternalSave: Boolean read FInternalSave write FInternalSave;
  68.     property Overwrite: Boolean read FOverwrite write FOverwrite;
  69.     property Records[Index: DWORD]: TJournalRecord read GetRecord write SetRecord;
  70.     property RecordCount: DWORD read GetRecordCount;
  71.  
  72.     property ModuleName: string read FModuleName;
  73.     property ModuleVersion: string read FModuleVersion;
  74.   end;
  75.  
  76. function FormatTimer(ATime: Comp): string;
  77.  
  78. const
  79.   EventLevels: array[TEventLevel] of string = ('Start  ',
  80.                                                'System ',
  81.                                                'Begin  ',
  82.                                                'End    ',
  83.                                                'Info   ',
  84.                                                'Warning',
  85.                                                'Error  ',
  86.                                                'Data   ',
  87.                                                'Action ');
  88.   extMJF = '.mjf';
  89.  
  90. resourcestring
  91.   rsJournalStartedInEXE = 'Process "%s" version "%s" running on "%s\%s"';
  92.   rsJournalFinishedInEXE = 'Process terminated with exit code %d';
  93.   rsJournalStartedInModule = 'Module "%s" version "%s" was called from "%s" version "%s" running on "%s\%s"';
  94.   rsJournalFinishedInModule = 'Module removed from memory';
  95.  
  96. implementation
  97.  
  98.