Browse Source

--- Merging r14960 into '.':
U rtl/objpas/sysutils/osutilsh.inc
U packages/fcl-base/src/eventlog.pp
U packages/fcl-base/src/custapp.pp
--- Merging r14964 into '.':
U utils/fppkg/fppkg.pp
--- Merging r14991 into '.':
C packages/fcl-web/src/custweb.pp
Summary of conflicts:
Text conflicts: 1

git-svn-id: branches/fixes_2_4@15254 -

joost 15 years ago
parent
commit
54d175d07c

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

@@ -63,6 +63,7 @@ Type
     Function CheckOptions(Const ShortOptions : String; Const LongOpts : String) : String;
     Function CheckOptions(Const ShortOptions : String; Const LongOpts : String) : String;
     Procedure GetEnvironmentList(List : TStrings;NamesOnly : Boolean);
     Procedure GetEnvironmentList(List : TStrings;NamesOnly : Boolean);
     Procedure GetEnvironmentList(List : TStrings);
     Procedure GetEnvironmentList(List : TStrings);
+    Procedure Log(EventType : TEventType; Msg : String); virtual;
     // Delphi properties
     // Delphi properties
     property ExeName: string read GetExeName;
     property ExeName: string read GetExeName;
     property HelpFile: string read FHelpFile write FHelpFile;
     property HelpFile: string read FHelpFile write FHelpFile;
@@ -222,6 +223,12 @@ begin
   // Do nothing. Override in descendent classes.
   // Do nothing. Override in descendent classes.
 end;
 end;
 
 
+Procedure TCustomApplication.Log(EventType : TEventType; Msg : String);
+
+begin
+  // Do nothing. Override in descendent classes.
+end;
+
 constructor TCustomApplication.Create(AOwner: TComponent);
 constructor TCustomApplication.Create(AOwner: TComponent);
 begin
 begin
   inherited Create(AOwner);
   inherited Create(AOwner);

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

@@ -23,7 +23,6 @@ uses SysUtils,Classes;
 
 
 Type
 Type
   TEventLog = Class;
   TEventLog = Class;
-  TEventType = (etCustom,etInfo,etWarning,etError,etDebug);
   TLogType = (ltSystem,ltFile);
   TLogType = (ltSystem,ltFile);
   TLogCodeEvent = Procedure (Sender : TObject; Var Code : DWord) of Object;
   TLogCodeEvent = Procedure (Sender : TObject; Var Code : DWord) of Object;
   TLogCategoryEvent = Procedure (Sender : TObject; Var Code : Word) of Object;
   TLogCategoryEvent = Procedure (Sender : TObject; Var Code : Word) of Object;

+ 25 - 1
packages/fcl-web/src/custweb.pp

@@ -21,7 +21,7 @@ unit custweb;
 Interface
 Interface
 
 
 uses
 uses
-  CustApp,Classes,SysUtils, httpdefs, fphttp;
+  CustApp,Classes,SysUtils, httpdefs, fphttp, eventlog;
 
 
 Const
 Const
   CGIVarCount = 36;
   CGIVarCount = 36;
@@ -88,6 +88,8 @@ Type
     FHandleGetOnPost : Boolean;
     FHandleGetOnPost : Boolean;
     FRedirectOnError : Boolean;
     FRedirectOnError : Boolean;
     FRedirectOnErrorURL : String;
     FRedirectOnErrorURL : String;
+    FEventLog: TEventLog;
+    function GetEventLog: TEventLog;
   protected
   protected
     Function GetModuleName(Arequest : TRequest) : string;
     Function GetModuleName(Arequest : TRequest) : string;
     function WaitForRequest(out ARequest : TRequest; out AResponse : TResponse) : boolean; virtual; abstract;
     function WaitForRequest(out ARequest : TRequest; out AResponse : TResponse) : boolean; virtual; abstract;
@@ -99,11 +101,13 @@ Type
     Function GetAdministrator : String; virtual;
     Function GetAdministrator : String; virtual;
   Public
   Public
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
+    destructor Destroy; override;
     Procedure CreateForm(AClass : TComponentClass; out Reference);
     Procedure CreateForm(AClass : TComponentClass; out Reference);
     Procedure Initialize; override;
     Procedure Initialize; override;
     Procedure ShowException(E: Exception);override;
     Procedure ShowException(E: Exception);override;
     Procedure DoHandleRequest(ARequest : TRequest; AResponse : TResponse);
     Procedure DoHandleRequest(ARequest : TRequest; AResponse : TResponse);
     Procedure HandleRequest(ARequest : TRequest; AResponse : TResponse); virtual;
     Procedure HandleRequest(ARequest : TRequest; AResponse : TResponse); virtual;
+    Procedure Log(EventType: TEventType; Msg: String); override;
     Property HandleGetOnPost : Boolean Read FHandleGetOnPost Write FHandleGetOnPost;
     Property HandleGetOnPost : Boolean Read FHandleGetOnPost Write FHandleGetOnPost;
     Property RedirectOnError : boolean Read FRedirectOnError Write FRedirectOnError;
     Property RedirectOnError : boolean Read FRedirectOnError Write FRedirectOnError;
     Property RedirectOnErrorURL : string Read FRedirectOnErrorURL Write FRedirectOnErrorURL;
     Property RedirectOnErrorURL : string Read FRedirectOnErrorURL Write FRedirectOnErrorURL;
@@ -114,6 +118,7 @@ Type
     Property Email : String Read GetEmail Write FEmail;
     Property Email : String Read GetEmail Write FEmail;
     Property Administrator : String Read GetAdministrator Write FAdministrator;
     Property Administrator : String Read GetAdministrator Write FAdministrator;
     property OnShowRequestException: TOnShowRequestException read FOnShowRequestException write FOnShowRequestException;
     property OnShowRequestException: TOnShowRequestException read FOnShowRequestException write FOnShowRequestException;
+    Property EventLog: TEventLog read GetEventLog;
   end;
   end;
 
 
   EFPWebError = Class(Exception);
   EFPWebError = Class(Exception);
@@ -281,6 +286,11 @@ begin
   end;
   end;
 end;
 end;
 
 
+procedure TCustomWebApplication.Log(EventType: TEventType; Msg: String);
+begin
+  EventLog.log(EventType,Msg);
+end;
+
 Procedure TCustomWebApplication.Initialize;
 Procedure TCustomWebApplication.Initialize;
 
 
 begin
 begin
@@ -288,6 +298,13 @@ begin
   Inherited;
   Inherited;
 end;
 end;
 
 
+function TCustomWebApplication.GetEventLog: TEventLog;
+begin
+  if not assigned(FEventLog) then
+    FEventLog := TEventLog.Create(self);
+  Result := FEventLog;
+end;
+
 function TCustomWebApplication.GetModuleName(Arequest: TRequest): string;
 function TCustomWebApplication.GetModuleName(Arequest: TRequest): string;
 var
 var
   S : String;
   S : String;
@@ -341,6 +358,13 @@ begin
   FRedirectOnErrorURL := '';
   FRedirectOnErrorURL := '';
 end;
 end;
 
 
+destructor TCustomWebApplication.Destroy;
+begin
+  if assigned(FEventLog) then
+    FEventLog.Free;
+  inherited Destroy;
+end;
+
 procedure TCustomWebApplication.CreateForm(AClass: TComponentClass; out Reference);
 procedure TCustomWebApplication.CreateForm(AClass: TComponentClass; out Reference);
 begin
 begin
   TComponent(Reference):=AClass.Create(Self);
   TComponent(Reference):=AClass.Create(Self);

+ 3 - 0
rtl/objpas/sysutils/osutilsh.inc

@@ -52,6 +52,9 @@ Type
   TGetTempDirEvent  = Function (Global : Boolean) : String;
   TGetTempDirEvent  = Function (Global : Boolean) : String;
   TGetTempFileEvent = Function (Const Dir,Prefix : String) : String;
   TGetTempFileEvent = Function (Const Dir,Prefix : String) : String;
 
 
+Type
+  TEventType = (etCustom,etInfo,etWarning,etError,etDebug);
+
 Var
 Var
   OnGetVendorName      : TGetVendorNameEvent;
   OnGetVendorName      : TGetVendorNameEvent;
   OnGetApplicationName : TGetAppNameEvent;
   OnGetApplicationName : TGetAppNameEvent;

+ 7 - 7
utils/fppkg/fppkg.pp

@@ -90,9 +90,9 @@ begin
   GlobalOptions.CompilerConfig:=GlobalOptions.DefaultCompilerConfig;
   GlobalOptions.CompilerConfig:=GlobalOptions.DefaultCompilerConfig;
   // Tracing of what we've done above, need to be done after the verbosity is set
   // Tracing of what we've done above, need to be done after the verbosity is set
   if GeneratedConfig then
   if GeneratedConfig then
-    Log(vlDebug,SLogGeneratingGlobalConfig,[cfgfile])
+    pkgglobals.Log(vlDebug,SLogGeneratingGlobalConfig,[cfgfile])
   else
   else
-    Log(vlDebug,SLogLoadingGlobalConfig,[cfgfile]);
+    pkgglobals.Log(vlDebug,SLogLoadingGlobalConfig,[cfgfile]);
   // Log configuration
   // Log configuration
   GlobalOptions.LogValues;
   GlobalOptions.LogValues;
 end;
 end;
@@ -114,7 +114,7 @@ begin
   S:=GlobalOptions.CompilerConfigDir+GlobalOptions.CompilerConfig;
   S:=GlobalOptions.CompilerConfigDir+GlobalOptions.CompilerConfig;
   if FileExists(S) then
   if FileExists(S) then
     begin
     begin
-      Log(vlDebug,SLogLoadingCompilerConfig,[S]);
+      pkgglobals.Log(vlDebug,SLogLoadingCompilerConfig,[S]);
       CompilerOptions.LoadCompilerFromFile(S)
       CompilerOptions.LoadCompilerFromFile(S)
     end
     end
   else
   else
@@ -122,7 +122,7 @@ begin
       // Generate a default configuration if it doesn't exists
       // Generate a default configuration if it doesn't exists
       if GlobalOptions.CompilerConfig='default' then
       if GlobalOptions.CompilerConfig='default' then
         begin
         begin
-          Log(vlDebug,SLogGeneratingCompilerConfig,[S]);
+          pkgglobals.Log(vlDebug,SLogGeneratingCompilerConfig,[S]);
           CompilerOptions.InitCompilerDefaults;
           CompilerOptions.InitCompilerDefaults;
           CompilerOptions.SaveCompilerToFile(S);
           CompilerOptions.SaveCompilerToFile(S);
           if CompilerOptions.Dirty then
           if CompilerOptions.Dirty then
@@ -137,7 +137,7 @@ begin
   S:=GlobalOptions.CompilerConfigDir+GlobalOptions.FPMakeCompilerConfig;
   S:=GlobalOptions.CompilerConfigDir+GlobalOptions.FPMakeCompilerConfig;
   if FileExists(S) then
   if FileExists(S) then
     begin
     begin
-      Log(vlDebug,SLogLoadingFPMakeCompilerConfig,[S]);
+      pkgglobals.Log(vlDebug,SLogLoadingFPMakeCompilerConfig,[S]);
       FPMakeCompilerOptions.LoadCompilerFromFile(S);
       FPMakeCompilerOptions.LoadCompilerFromFile(S);
       if FPMakeCompilerOptions.Dirty then
       if FPMakeCompilerOptions.Dirty then
         FPMakeCompilerOptions.SaveCompilerToFile(S);
         FPMakeCompilerOptions.SaveCompilerToFile(S);
@@ -307,7 +307,7 @@ begin
           pkghandler.ExecuteAction('','update');
           pkghandler.ExecuteAction('','update');
         except
         except
           on E: Exception do
           on E: Exception do
-            Log(vlWarning,E.Message);
+            pkgglobals.Log(vlWarning,E.Message);
         end;
         end;
       end;
       end;
     LoadLocalAvailableRepository;
     LoadLocalAvailableRepository;
@@ -346,7 +346,7 @@ begin
               end
               end
             else
             else
               begin
               begin
-                Log(vlDebug,SLogCommandLineAction,['['+ParaPackages[i]+']',ParaAction]);
+                pkgglobals.Log(vlDebug,SLogCommandLineAction,['['+ParaPackages[i]+']',ParaAction]);
                 pkghandler.ExecuteAction(ParaPackages[i],ParaAction);
                 pkghandler.ExecuteAction(ParaPackages[i],ParaAction);
               end;
               end;
           end;
           end;