Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelJustin committed Jul 15, 2016
2 parents f77c458 + a0c60fe commit 19c5b57
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/main/djLoggerFactory.pas
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ implementation

uses
NOPLogger,
SysUtils;
SysUtils, SyncObjs;

resourcestring
SLF4PTag = 'SLF4P: ';
Expand All @@ -44,17 +44,24 @@ implementation

var
LoggerFactory: ILoggerFactory;
CriticalSection: TCriticalSection;

procedure RegisterFactory(const AFactory: ILoggerFactory);
begin
Assert(Assigned(AFactory));

if Assigned(LoggerFactory) then
begin
WriteLn(SLF4PTag + WarnOverwrite);
end;
CriticalSection.Enter;
try
if Assigned(LoggerFactory) then
begin
WriteLn(SLF4PTag + WarnOverwrite);
end;

LoggerFactory := AFactory;

LoggerFactory := AFactory;
finally
CriticalSection.Leave;
end;
end;

{ TdjLoggerFactory }
Expand All @@ -76,4 +83,10 @@ class function TdjLoggerFactory.GetLogger(const AName: string): ILogger;
Result := LoggerFactory.GetLogger(AName);
end;

initialization
CriticalSection := TCriticalSection.Create;

finalization
CriticalSection.Free;

end.

0 comments on commit 19c5b57

Please sign in to comment.