Skip to content

Commit 7515d0d

Browse files
committed
Update 2.1
1 parent 78cdc9a commit 7515d0d

14 files changed

+1383
-74
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
2+
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
3+
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
4+
program AdvancedServerLoggerDemo;
5+
6+
(*
7+
Be sure to add the following settings to the project options:
8+
9+
1 : Under "Project > Options > Building > Delphi Compiler > Search Path",
10+
add the path to the "stub" component source. In this example this is:
11+
..\..\Component Library Source
12+
Also add:
13+
..\..\Common
14+
15+
2 : Under "Project > Options > Building > TMS Web > Compile",
16+
add the path to the "real" component source. In this example this is:
17+
..\..\Core Source
18+
Also add:
19+
..\..\Common
20+
21+
3 : If the server side php script is maintained and deployed with this
22+
TMS Web project as well, add ".php" (w/o quotes) to
23+
24+
"Project > Options > Building > TMS Web > Compile >Automatically copied file suffixes"
25+
26+
and add the php file itself to the project for deployment. In this demo,
27+
this is "API.php", to be found here: <your project path>\Server\PHP
28+
*)
29+
30+
uses
31+
Vcl.Forms,
32+
WEBLib.Forms,
33+
Unit1 in 'Unit1.pas' {Form1: TWebForm} {*.html};
34+
35+
{$R *.res}
36+
37+
begin
38+
Application.Initialize;
39+
Application.MainFormOnTaskbar := True;
40+
Application.CreateForm(TForm1, Form1);
41+
Application.Run;
42+
end.
43+

Demo/Advanced/AdvancedServerLoggerDemo.dproj

Lines changed: 951 additions & 0 deletions
Large diffs are not rendered by default.

Demo/Unit1.dfm renamed to Demo/Advanced/Unit1.dfm

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object Form1: TForm1
22
Width = 290
3-
Height = 180
3+
Height = 151
44
OnCreate = WebFormCreate
55
object LabVersion: TWebLabel
66
Left = 195
@@ -13,18 +13,9 @@ object Form1: TForm1
1313
HeightPercent = 100.000000000000000000
1414
WidthPercent = 100.000000000000000000
1515
end
16-
object WebLabel2: TWebLabel
17-
Left = 40
18-
Top = 80
19-
Width = 145
20-
Height = 13
21-
Caption = 'Fail after this nr. of responses'
22-
HeightPercent = 100.000000000000000000
23-
WidthPercent = 100.000000000000000000
24-
end
2516
object BtnLogOneLine: TWebButton
2617
Left = 15
27-
Top = 105
18+
Top = 80
2819
Width = 156
2920
Height = 25
3021
Caption = 'Write 1 line to console'
@@ -45,7 +36,7 @@ object Form1: TForm1
4536
end
4637
object BtnLogMioLines: TWebButton
4738
Left = 15
48-
Top = 136
39+
Top = 111
4940
Width = 156
5041
Height = 25
5142
Caption = 'Write 1 mio. lines to console'
@@ -54,20 +45,20 @@ object Form1: TForm1
5445
WidthPercent = 100.000000000000000000
5546
OnClick = BtnLogMioLinesClick
5647
end
57-
object CbxCustomResponseHandler: TWebCheckBox
48+
object CbxProvokeError: TWebCheckBox
5849
Left = 15
5950
Top = 45
60-
Width = 241
51+
Width = 170
6152
Height = 22
62-
Caption = 'Custom server response handling enabled'
53+
Caption = 'Fail after this nr. of responses'
6354
ChildOrder = 1
6455
HeightPercent = 100.000000000000000000
6556
WidthPercent = 100.000000000000000000
66-
OnClick = CbxCustomResponseHandlerClick
57+
OnClick = CbxProvokeErrorClick
6758
end
6859
object EdNrRespToFail: TWebEdit
6960
Left = 206
70-
Top = 77
61+
Top = 45
7162
Width = 50
7263
Height = 22
7364
ChildOrder = 4
@@ -76,13 +67,14 @@ object Form1: TForm1
7667
WidthPercent = 100.000000000000000000
7768
end
7869
object ServerLogger1: TServerLogger
79-
Version = '2.0'
70+
Version = '2.1'
8071
LogfileName = 'Demo'
81-
ServerURL = 'http://localhost/myAMI//WWYPHP/REST/API.php'
72+
ServerURL = 'API.php'
8273
SendInterval = 1
8374
CacheLines = 10000
8475
Retries = 0
8576
OnError = ServerLogger1Error
77+
OnServerResponse = ServerLogger1ServerResponse
8678
EnvelopeDataKey = 'LogData'
8779
EnvelopeJSON.Strings = (
8880
'{'
@@ -91,6 +83,6 @@ object Form1: TForm1
9183
'}')
9284
Enabled = True
9385
Left = 205
94-
Top = 115
86+
Top = 90
9587
end
9688
end
File renamed without changes.

Demo/Unit1.pas renamed to Demo/Advanced/Unit1.pas

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
communication with an arbitrary server, to which the logger data is
55
sent.
66
7-
In this very example, the TServerLogger component talks to a REST API.
8-
Unfortunately, this demo is therefore quite unlikely to work in your
9-
own environment, but the explanations might come useful to establish
10-
your own server communication.
7+
In this very example, the TServerLogger component talks to a mocked
8+
REST API, implemented by the provided PHP script named "API.php".
119
1210
1. Use property EnvelopeJSON to put a JSON envelope around the data
1311
to be sent to the server. In this example, this is:
@@ -37,7 +35,7 @@
3735
}
3836
3937
4. Use property ServerURL to define the resource on the server side to talk
40-
to. In this example, a REST API is addressed.
38+
to. In this example, it is just a mockup API named "API.php".
4139
4240
3. Use property OnServerResponse to set a custom server response examination
4341
handler that examines the response received from the server. In this
@@ -76,17 +74,16 @@ TForm1=class(TWebForm)
7674
ServerLogger1: TServerLogger;
7775
CbxEnableLogging: TWebCheckBox;
7876
BtnLogMioLines: TWebButton;
79-
CbxCustomResponseHandler: TWebCheckBox;
77+
CbxProvokeError: TWebCheckBox;
8078
EdNrRespToFail: TWebEdit;
8179
LabVersion: TWebLabel;
82-
WebLabel2: TWebLabel;
8380
procedure WebFormCreate(Sender: TObject);
8481
procedure ServerLogger1Error(Sender: TObject; Status: Integer; ErrorMessage: string);
8582
procedure ServerLogger1ServerResponse(Sender: TObject; const HTTPStatus: Integer;
8683
const Response: string; var IsSuccess: Boolean; var ErrorMessage: string);
8784
procedure BtnLogOneLineClick(Sender: TObject);
8885
procedure CbxEnableLoggingClick(Sender: TObject);
89-
procedure CbxCustomResponseHandlerClick(Sender: TObject);
86+
procedure CbxProvokeErrorClick(Sender: TObject);
9087
[async] procedure BtnLogMioLinesClick(Sender: TObject);
9188
private
9289
FNrResponses : Integer;
@@ -180,7 +177,7 @@ procedure TForm1.ServerLogger1ServerResponse(Sender: TObject;
180177
{-----------}
181178

182179
// Custom examination of the response received from the server
183-
// This might be a typical response from a REST API:
180+
// These are possible responses from the mocked REST API:
184181
// {"Result":"OK","Version":101569}
185182
// {"Result":"Error","ErrorDetails":{"ErrorClass":"EBaseRESTError","ErrorMessage":"File not found"]},"Version":101569}
186183
try
@@ -254,23 +251,10 @@ procedure TForm1.CbxEnableLoggingClick(Sender: TObject);
254251
{------------------------------------}
255252

256253
// Toggle using a custom server response examination handler
257-
procedure TForm1.CbxCustomResponseHandlerClick(Sender: TObject);
258-
var WasEnabled: Boolean;
254+
procedure TForm1.CbxProvokeErrorClick(Sender: TObject);
259255
begin
260256
FNrResponses := 0;
261257
FNrRespToFail := StrToInt(EdNrRespToFail.Text);
262-
263-
// Changes to the configuration are only allowed when diabled
264-
WasEnabled := ServerLogger1.Enabled;
265-
if WasEnabled then ServerLogger1.Enabled := False;
266-
try
267-
if CbxCustomResponseHandler.Checked then
268-
ServerLogger1.OnServerResponse := Self.ServerLogger1ServerResponse
269-
else
270-
ServerLogger1.OnServerResponse := nil;
271-
finally
272-
if WasEnabled then ServerLogger1.Enabled := True;
273-
end;
274258
end;
275259

276260
{------------------------------------}
File renamed without changes.

Demo/ServerLoggerDemo.dpr renamed to Demo/Basic/BasicServerLoggerDemo.dpr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
// JCL_DEBUG_EXPERT_GENERATEJDBG OFF
22
// JCL_DEBUG_EXPERT_INSERTJDBG OFF
33
// JCL_DEBUG_EXPERT_DELETEMAPFILE OFF
4-
program ServerLoggerDemo;
4+
program BasicServerLoggerDemo;
55

66
(*
7-
Be sure to add the following 2 paths to the project options:
7+
Be sure to add the following settings to the project options:
88
99
1 : Under "Project > Options > Building > Delphi Compiler > Search Path",
1010
add the path to the "stub" component source. In this example this is:
11-
..\Component Library Source
11+
..\..\Component Library Source
1212
Also add:
13-
..\Common
13+
..\..\Common
1414
1515
2 : Under "Project > Options > Building > TMS Web > Compile",
1616
add the path to the "real" component source. In this example this is:
17-
..\Core Source
17+
..\..\Core Source
1818
Also add:
19-
..\Common
19+
..\..\Common
2020
2121
3 : If the server side php script is maintained and deployed with this
2222
TMS Web project as well, add ".php" (w/o quotes) to
2323
2424
"Project > Options > Building > TMS Web > Compile >Automatically copied file suffixes"
2525
2626
and add the php file itself to the project for deployment. In this demo,
27-
this is "LogIt.php", to be found here: <your project path>\PHP\Server
27+
this is "LogIt.php", to be found here: <your project path>\Server\PHP
2828
*)
2929

3030
uses
31-
Vcl.Forms,
32-
WEBLib.Forms,
33-
Unit1 in'Unit1.pas'{Form1: TWebForm}{*.html};
31+
Vcl.Forms,
32+
WEBLib.Forms,
33+
Unit1 in 'Unit1.pas' {Form1: TWebForm} {*.html};
3434

3535
{$R *.res}
3636

Demo/ServerLoggerDemo.dproj renamed to Demo/Basic/BasicServerLoggerDemo.dproj

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Platform Condition="'$(Platform)'==''">Win32</Platform>
99
<TargetedPlatforms>1</TargetedPlatforms>
1010
<AppType>Application</AppType>
11-
<MainSource>ServerLoggerDemo.dpr</MainSource>
11+
<MainSource>BasicServerLoggerDemo.dpr</MainSource>
1212
</PropertyGroup>
1313
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
1414
<Base>true</Base>
@@ -57,7 +57,7 @@
5757
<TMSWebProject>2</TMSWebProject>
5858
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
5959
<Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
60-
<SanitizedProjectName>ServerLoggerDemo</SanitizedProjectName>
60+
<SanitizedProjectName>BasicServerLoggerDemo</SanitizedProjectName>
6161
<TMSWebHTMLFile>index.html</TMSWebHTMLFile>
6262
</PropertyGroup>
6363
<PropertyGroup Condition="'$(Base_Win32)'!=''">
@@ -86,10 +86,10 @@
8686
<DCC_RemoteDebug>false</DCC_RemoteDebug>
8787
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
8888
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
89-
<TMSWebSourcePaths>$(TMSWebSourcePaths);..\Core Source;..\Common</TMSWebSourcePaths>
89+
<TMSWebSourcePaths>$(TMSWebSourcePaths);..\..\Core Source;..\..\Common</TMSWebSourcePaths>
9090
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
9191
<VerInfo_Locale>1033</VerInfo_Locale>
92-
<DCC_UnitSearchPath>..\Component Library Source;..\Common;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
92+
<DCC_UnitSearchPath>..\..\Component Library Source;..\..\Common;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
9393
<TMSWebPrivExts>$(TMSWebPrivExts);.php</TMSWebPrivExts>
9494
<TMSWebBrowser>7</TMSWebBrowser>
9595
</PropertyGroup>
@@ -121,7 +121,7 @@
121121
<DesignClass>TWebForm</DesignClass>
122122
</DCCReference>
123123
<None Include="index.html"/>
124-
<None Include="..\Server\LogIt.php"/>
124+
<None Include="..\..\Server\PHP\LogIt.php"/>
125125
<BuildConfiguration Include="Release">
126126
<Key>Cfg_2</Key>
127127
<CfgParent>Base</CfgParent>
@@ -140,7 +140,7 @@
140140
<BorlandProject>
141141
<Delphi.Personality>
142142
<Source>
143-
<Source Name="MainSource">ServerLoggerDemo.dpr</Source>
143+
<Source Name="MainSource">BasicServerLoggerDemo.dpr</Source>
144144
</Source>
145145
<Excluded_Packages>
146146
<Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\21.0\Bpl\PngComponents250.bpl">Png Components</Excluded_Packages>
@@ -149,19 +149,19 @@
149149
</Excluded_Packages>
150150
</Delphi.Personality>
151151
<Deployment Version="3">
152-
<DeployFile LocalName="index.html" Configuration="Debug" Class="ProjectFile">
152+
<DeployFile LocalName="Win32\Debug\BasicServerLoggerDemo.exe" Configuration="Debug" Class="ProjectOutput">
153153
<Platform Name="Win32">
154-
<RemoteDir>.\</RemoteDir>
154+
<RemoteName>BasicServerLoggerDemo.exe</RemoteName>
155155
<Overwrite>true</Overwrite>
156156
</Platform>
157157
</DeployFile>
158-
<DeployFile LocalName="Win32\Debug\ServerLoggerDemo.exe" Configuration="Debug" Class="ProjectOutput">
158+
<DeployFile LocalName="index.html" Configuration="Debug" Class="ProjectFile">
159159
<Platform Name="Win32">
160-
<RemoteName>ServerLoggerDemo.exe</RemoteName>
160+
<RemoteDir>.\</RemoteDir>
161161
<Overwrite>true</Overwrite>
162162
</Platform>
163163
</DeployFile>
164-
<DeployFile LocalName="..\Server\LogIt.php" Configuration="Debug" Class="ProjectFile">
164+
<DeployFile LocalName="..\..\Server\PHP\LogIt.php" Configuration="Debug" Class="ProjectFile">
165165
<Platform Name="Win32">
166166
<RemoteDir>.\</RemoteDir>
167167
<Overwrite>true</Overwrite>

Demo/Basic/Unit1.dfm

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
object Form1: TForm1
2+
Width = 290
3+
Height = 109
4+
OnCreate = WebFormCreate
5+
object LabVersion: TWebLabel
6+
Left = 195
7+
Top = 20
8+
Width = 61
9+
Height = 13
10+
Alignment = taRightJustify
11+
AutoSize = False
12+
Caption = 'Vers.: ---'
13+
HeightPercent = 100.000000000000000000
14+
WidthPercent = 100.000000000000000000
15+
end
16+
object BtnLogOneLine: TWebButton
17+
Left = 15
18+
Top = 45
19+
Width = 156
20+
Height = 25
21+
Caption = 'Write 1 line to console'
22+
HeightPercent = 100.000000000000000000
23+
WidthPercent = 100.000000000000000000
24+
OnClick = BtnLogOneLineClick
25+
end
26+
object CbxEnableLogging: TWebCheckBox
27+
Left = 15
28+
Top = 17
29+
Width = 131
30+
Height = 22
31+
Caption = 'Server logging enabled'
32+
ChildOrder = 1
33+
HeightPercent = 100.000000000000000000
34+
WidthPercent = 100.000000000000000000
35+
OnClick = CbxEnableLoggingClick
36+
end
37+
object BtnLogMioLines: TWebButton
38+
Left = 15
39+
Top = 76
40+
Width = 156
41+
Height = 25
42+
Caption = 'Write 1 mio. lines to console'
43+
ChildOrder = 2
44+
HeightPercent = 100.000000000000000000
45+
WidthPercent = 100.000000000000000000
46+
OnClick = BtnLogMioLinesClick
47+
end
48+
object ServerLogger1: TServerLogger
49+
Version = '2.1'
50+
LogfileName = 'Demo'
51+
ServerURL = 'LogIt.php'
52+
SendInterval = 3
53+
CacheLines = 10000
54+
Retries = 3
55+
OnError = ServerLogger1Error
56+
Enabled = True
57+
Left = 205
58+
Top = 55
59+
end
60+
end

0 commit comments

Comments
 (0)