Browse Source

* Applied patch from Luca Olivetti to ignore errors during logging

git-svn-id: trunk@11015 -
michael 17 years ago
parent
commit
40d26841cb
2 changed files with 4 additions and 2 deletions
  1. 2 0
      packages/fcl-base/src/eventlog.pp
  2. 2 2
      packages/fcl-base/src/win/eventlog.inc

+ 2 - 0
packages/fcl-base/src/eventlog.pp

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

+ 2 - 2
packages/fcl-base/src/win/eventlog.inc

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