* Applied patch from Luca Olivetti to ignore errors during logging

git-svn-id: trunk@11015 -
This commit is contained in:
michael 2008-05-19 18:56:46 +00:00
parent 35c0f78642
commit 40d26841cb
2 changed files with 4 additions and 2 deletions

View File

@ -34,6 +34,7 @@ Type
FLogHandle : Pointer;
FStream : TFileStream;
FActive: Boolean;
FRaiseExceptionOnError: Boolean;
FIdentification: String;
FDefaultEventType: TEventType;
FLogtype: TLogType;
@ -86,6 +87,7 @@ Type
Property Identification : String Read FIdentification Write SetIdentification;
Property LogType : TLogType Read Flogtype Write SetlogType;
Property Active : Boolean Read FActive write SetActive;
Property RaiseExceptionOnError : Boolean Read FRaiseExceptionOnError Write FRaiseExceptionOnError;
Property DefaultEventType : TEventType Read FDEfaultEventType Write FDefaultEventType;
Property FileName : String Read FFileName Write SetFileName;
Property TimeStampFormat : String Read FTimeStampFormat Write FTimeStampFormat;

View File

@ -30,7 +30,7 @@ Procedure TEventLog.ActivateSystemLog;
begin
CheckIdentification;
FLogHandle := Pointer(OpenEventLog(Nil,Pchar(Identification)));
If FLogHandle=Nil then
If (FLogHandle=Nil) and FRaiseExceptionOnError then
Raise ELogError.CreateFmt(SErrNoSysLog,[GetLastError]);
end;
@ -60,7 +60,7 @@ begin
FEventID:=MapTypeToEventID(EventType);
FEventType:=MapTypeToEvent(EventType);
P:=PChar(Msg);
If Not ReportEvent(Cardinal(FLogHandle),FEventType,FCategory,FEventID,Nil,1,0,@P,Nil) then
If Not ReportEvent(Cardinal(FLogHandle),FEventType,FCategory,FEventID,Nil,1,0,@P,Nil) and FRaiseExceptionOnError then
begin
I:=GetLastError;
Raise ELogError.CreateFmt(SErrLogFailed,[I]);