2
0
Эх сурвалжийг харах

* Applied adapted patch from Simon Ameis to add log with formatting capabilities (bug ID 29262)

git-svn-id: trunk@32767 -
michael 9 жил өмнө
parent
commit
ac1768adb0

+ 12 - 0
packages/fcl-base/src/custapp.pp

@@ -79,6 +79,7 @@ Type
     Procedure GetEnvironmentList(List : TStrings;NamesOnly : Boolean);
     Procedure GetEnvironmentList(List : TStrings);
     Procedure Log(EventType : TEventType; const Msg : String);
+    Procedure Log(EventType : TEventType; const Fmt : String; const Args : array of const);
     // Delphi properties
     property ExeName: string read GetExeName;
     property HelpFile: string read FHelpFile write FHelpFile;
@@ -265,6 +266,17 @@ begin
     DoLog(EventType,Msg);
 end;
 
+procedure TCustomApplication.Log(EventType: TEventType; const Fmt: String;
+  const Args: array of const);
+begin
+  try
+    Log(EventType, Format(Fmt, Args));
+  except
+    On E : Exception do
+      Log(etError,Format('Error formatting message "%s" with %d arguments: %s',[Fmt,Length(Args),E.Message]));
+  end  
+end;
+
 constructor TCustomApplication.Create(AOwner: TComponent);
 begin
   inherited Create(AOwner);