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 >
Wrap
Text File
|
2003-10-10
|
4KB
|
98 lines
{*******************************************************}
{ }
{ MiTeC System Information Component }
{ Journal Object }
{ version 8.4 for Delphi 5,6,7 }
{ }
{ Copyright ⌐ 1997,2003 Michal Mutl }
{ }
{*******************************************************}
{$INCLUDE MITEC_DEF.INC}
unit MiTeC_Journal;
interface
uses Windows, Classes, SysUtils;
type
TEventLevel = (elStart, elSystem, elBegin, elEnd, elInformation, elWarning,
elError, elData, elAction);
TJournalRecord = record
Level: TEventLevel;
Timestamp: TDateTime;
TimestampStr: string;
Message: string;
end;
TJournalBuffer = array of TJournalRecord;
TJournal = class
private
FProcessHandle: THandle;
FFile: TFileStream;
FBuffer: TJournalBuffer;
FInternalSave: Boolean;
FFilename, FMachine, FUser: string;
FOverwrite: Boolean;
FStartTime,FStopTime: comp;
FInternalTime: array of Comp;
FModuleName: string;
FModuleVersion: string;
function GetRecord(Index: DWORD): TJournalRecord;
function GetRecordCount: DWORD;
procedure SetRecord(Index: DWORD; const Value: TJournalRecord);
procedure AddRecord(ATimestamp: TDateTime; AMessage: string; ALevel: TEventLevel); overload;
procedure AddRecord(ATimestamp: string; AMessage: string; ALevel: TEventLevel); overload;
procedure AddRecord(ARecord: TJournalRecord); overload;
procedure CreateFile;
procedure PushTime(Time: comp);
function PopTime: comp;
public
constructor Create(ADir,AFileNamePrefix: string; AInternalSave,AOverwrite,AReadOnly: boolean);
destructor Destroy; override;
procedure WriteEvent(AMessage: string; ALevel: TEventLevel);
procedure WriteSpace;
procedure WriteEventFmt(const AFormat: string; const AArgs: array of const; ALevel: TEventLevel);
procedure LoadFromFile(AFilename: string);
procedure SaveToFile(AFilename: string);
procedure Clear;
procedure StartTimer;
function StopTimer: Comp;
property FileName: string read FFilename;
property InternalSave: Boolean read FInternalSave write FInternalSave;
property Overwrite: Boolean read FOverwrite write FOverwrite;
property Records[Index: DWORD]: TJournalRecord read GetRecord write SetRecord;
property RecordCount: DWORD read GetRecordCount;
property ModuleName: string read FModuleName;
property ModuleVersion: string read FModuleVersion;
end;
function FormatTimer(ATime: Comp): string;
const
EventLevels: array[TEventLevel] of string = ('Start ',
'System ',
'Begin ',
'End ',
'Info ',
'Warning',
'Error ',
'Data ',
'Action ');
extMJF = '.mjf';
resourcestring
rsJournalStartedInEXE = 'Process "%s" version "%s" running on "%s\%s"';
rsJournalFinishedInEXE = 'Process terminated with exit code %d';
rsJournalStartedInModule = 'Module "%s" version "%s" was called from "%s" version "%s" running on "%s\%s"';
rsJournalFinishedInModule = 'Module removed from memory';
implementation