THotLog |
[ Home ] |
Log file properties |
hLog writes everything in a file which is owned and managed by the writer thread. For that reason, the log file definition object has been made a property of the wrtiter thread, instead of declaring more anf more methodes into THotLog itself.
You will then have to acces it through the writer thread instance: hLog.hlWriter.hlFileDef.someProperty.
Please note also that it is obvious that those settings can be
changed before you call
hLog.StartLogging or a hLog.Add procedure for the first time.
It's not possible to change some log file and writer thread properties later.
OneKilobyte = 1024; OneMegabyte = OneKilobyte * 1024; TenMegabyte = OneMegabyte * 10;Default: 0 (unlimited)
Examples of use (with an exe being for example "C:\tools\MyProg.exe"):
=> Changing nothing:
The log file full name will be "C:\tools\MyProg.log"
Only one file. Will be overwritten at every startup.
=> Setting the ddName:
hLog.hlWriter.hlFileDef.ddname := 'AnotherLogName';
=> Defining a generation based file, limited to five generations:
hLog.hlWriter.hlFileDef.GdgMax := 5;
=> Defining a size limit for the log file, and a maximum of five generations:
hLog.hlWriter.hlFileDef.GdgMax := 5;
hLog.hlWriter.hlFileDef.LogFileMaxSize := OneKilobyte;
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls, HotLog; type TForm1 = class(TForm) Timer1: TTimer; Memo1: TMemo; procedure Timer1Timer (Sender: TObject); procedure FormCreate (Sender: TObject): procedure FormDestroy (Sender: TObject); private { Private declarations } public { Public declarations } end; implementation {$R *.dfm} const SeventyCharsOfJunk = '1234567890123456789012345678901234567890123456789012345678901234567890'; var Counter: integer; procedure TForm1.Timer1Timer(Sender: TObject); begin hLog.AddStr('Counter = ' + IntToStr(Counter) + ' ' + DateTimeToStr(Now) + SeventyCharsOfJunk); inc(counter); end; procedure TForm1.FormCreate(Sender: TObject); begin Counter := 1; hLog.hlWriter.hlFileDef.path := ExtractFilePath(Application.ExeName); hLog.hlWriter.hlFileDef.UseFileSizeLimit := true; hLog.hlWriter.hlFileDef.LogFileMaxSize := OneKilobyte; hLog.hlWriter.hlFileDef.UseSafeFilenames := true; if hLog.hlWriter.hlFileDef.UseSafeFilenames then begin hLog.hlWriter.hlFileDef.BuildSafeFilename; hLog.hlWriter.hlFileDef.SafeGdgMax := 5; end else begin hLog.hlWriter.hlFileDef.ddname := 'LogTest'; hLog.hlWriter.hlFileDef.GdgMax := 5; end; hlog.SetLogFileTimerInterval(OneMinute); hLog.DisplayFeedBackInto(Memo1); hLog.ScrollMemo(true); hLog.SetMemoLimit(5000); hlog.StartLogging; end; procedure TForm1.FormDestroy(Sender: TObject); begin hlog.StopVisualFeedBack; end;
THotLog |