1
0
mirror of synced 2024-09-16 17:06:08 +00:00

FS#23 - Access Violation when using sub-categories

This commit is contained in:
Mark van Renswoude 2015-03-19 08:56:52 +00:00
parent 437655693e
commit 09e3b42610
2 changed files with 21 additions and 2 deletions

View File

@ -271,8 +271,25 @@ end;
procedure TMainForm.btnCategoryClick(Sender: TObject);
procedure Category2(ALog: IX2Log);
begin
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.Category('Test').Info(edtMessage.Text);
FLog.Info('Categories');
Category1(FLog.Category('Test'));
FLog.Info('/Categories');
end;

View File

@ -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;