![]() |
![]() ![]() ![]() |
acThreadSafeLog component.
|
type
|
TacThreadSafeLogCustomPrefixEvent = procedure(Sender: TObject; var Prefix: String) of object;
|
|
property OnCustomPrefix: TacThreadSafeLogCustomPrefixEvent;
|
The OnCustomPrefix event occurs when the component is about to append new line to the log file. It allows to specify custom prefix before each line of logged text. For example, you can specify current time, or identifier or calling thread or something else, which can not be specified in Options property and can not be put as prefix automatically.
|
procedure TForm1.acThreadSafeLog1CustomPrefix(Sender: TObject;
|
var Prefix: string);
|
var
|
TickDiff: DWord;
|
begin
|
// basically to specify the prefix, just put required text to Prefix parameter
|
Prefix := 'My custom prefix';
|
|
// here is more complicated example
|
TickDiff := GetTickCount - FStartTime;
|
Prefix := Format('[%d.%3.3d %s %d] %s', [TickDiff div 1000, TickDiff mod 1000,
|
FormatDateTime(FDateTimeFormat, Now), GetCurrentThreadID, Text]);
|
end;
|
Options and DateTimeFormat properties.
|