Browse Source

* Writing to file log now also will raise an error

git-svn-id: trunk@11016 -
michael 17 years ago
parent
commit
7dff0e91e6
1 changed files with 16 additions and 7 deletions
  1. 16 7
      packages/fcl-base/src/eventlog.pp

+ 16 - 7
packages/fcl-base/src/eventlog.pp

@@ -102,12 +102,13 @@ Type
 
 
 Resourcestring
 Resourcestring
 
 
-  SLogInfo    = 'Info';
-  SLogWarning = 'Warning';
-  SLogError   = 'Error';
-  SLogDebug   = 'Debug';
-  SLogCustom  = 'Custom (%d)';
-
+  SLogInfo      = 'Info';
+  SLogWarning   = 'Warning';
+  SLogError     = 'Error';
+  SLogDebug     = 'Debug';
+  SLogCustom    = 'Custom (%d)';
+  SErrLogFailedMsg = 'Failed to log entry (Error: %s)';
+  
 implementation
 implementation
 
 
 {$i eventlog.inc}
 {$i eventlog.inc}
@@ -190,7 +191,15 @@ begin
   TS:=FormatDateTime(FTimeStampFormat,Now);
   TS:=FormatDateTime(FTimeStampFormat,Now);
   T:=EventTypeToString(EventType);
   T:=EventTypeToString(EventType);
   S:=Format('%s [%s %s] %s%s',[Identification,TS,T,Msg,LineEnding]);
   S:=Format('%s [%s %s] %s%s',[Identification,TS,T,Msg,LineEnding]);
-  FStream.Write(S[1],Length(S));
+  try
+    FStream.WriteBuffer(S[1],Length(S));
+    S:='';
+  except
+    On E : Exception do
+      S:=E.Message;
+  end;  
+  If (S<>'') and RaiseExceptionOnError then
+    Raise ELogError.CreateFmt(SErrLogFailedMsg,[S]);
 end;
 end;
 
 
 procedure TEventLog.Log(Fmt: String; Args: array of const);
 procedure TEventLog.Log(Fmt: String; Args: array of const);