FS#23 - Access Violation when using sub-categories
This commit is contained in:
parent
437655693e
commit
09e3b42610
@ -271,8 +271,25 @@ end;
|
||||
|
||||
|
||||
procedure TMainForm.btnCategoryClick(Sender: TObject);
|
||||
|
||||
procedure Category2(ALog: IX2Log);
|
||||
begin
|
||||
FLog.Category('Test').Info(edtMessage.Text);
|
||||
ALog.Info(edtMessage.Text);
|
||||
end;
|
||||
|
||||
|
||||
procedure Category1(ALog: IX2Log);
|
||||
begin
|
||||
ALog.Info('Category 1');
|
||||
Category2(ALog.Category('Sub-category'));
|
||||
ALog.Info('/Category 1');
|
||||
end;
|
||||
|
||||
|
||||
begin
|
||||
FLog.Info('Categories');
|
||||
Category1(FLog.Category('Test'));
|
||||
FLog.Info('/Categories');
|
||||
end;
|
||||
|
||||
|
||||
|
@ -8,6 +8,8 @@ uses
|
||||
|
||||
|
||||
type
|
||||
TX2LogCategoryDecoratorClass = class of TX2LogCategoryDecorator;
|
||||
|
||||
TX2LogCategoryDecorator = class(TInterfacedObject, IX2Log)
|
||||
private
|
||||
FCategoryName: string;
|
||||
@ -106,7 +108,7 @@ end;
|
||||
function TX2LogCategoryDecorator.Category(const ACategory: string): IX2Log;
|
||||
begin
|
||||
if Assigned(DecoratedLog) then
|
||||
Result := Self.Create(DecoratedLog, GetCategory(ACategory));
|
||||
Result := (TX2LogCategoryDecoratorClass(Self.ClassType)).Create(DecoratedLog, GetCategory(ACategory));
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user