Exception handling in LogFile observer
Prevents thread from exiting and not logging anything after
This commit is contained in:
parent
97239e26eb
commit
7ff223a1f6
@ -153,11 +153,13 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
fileName := GetFileName(AEntry);
|
fileName := GetFileName(AEntry);
|
||||||
ForceDirectories(ExtractFilePath(fileName));
|
if not ForceDirectories(ExtractFilePath(fileName)) then
|
||||||
|
exit;
|
||||||
|
|
||||||
line := TextFormatter.GetText(TX2LogFileTextFormatterHelper.Create(AEntry, fileName, LogDetails),
|
line := TextFormatter.GetText(TX2LogFileTextFormatterHelper.Create(AEntry, fileName, LogDetails),
|
||||||
AEntry.Level, AEntry.DateTime, AEntry.Message, AEntry.Category, AEntry.Details);
|
AEntry.Level, AEntry.DateTime, AEntry.Message, AEntry.Category, AEntry.Details);
|
||||||
|
|
||||||
|
try
|
||||||
{ Append line to log file }
|
{ Append line to log file }
|
||||||
writer := TFile.AppendText(fileName);
|
writer := TFile.AppendText(fileName);
|
||||||
try
|
try
|
||||||
@ -165,6 +167,11 @@ begin
|
|||||||
finally
|
finally
|
||||||
FreeAndNil(writer);
|
FreeAndNil(writer);
|
||||||
end;
|
end;
|
||||||
|
except
|
||||||
|
{ If we retry for an amount of time the buffers will just backlog,
|
||||||
|
so for now just carry on. }
|
||||||
|
on E:EInOutError do;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user