41 |
|
procedure SetupSignalHandler; |
42 |
|
{$ENDIF} |
43 |
|
procedure HandleOnSQL(EventText: String; EventTime : TDateTime); |
44 |
+ |
procedure ShowStatistics(Sender: TObject); |
45 |
|
protected |
46 |
|
procedure CreateObjects(Application: TTestApplication); override; |
47 |
|
function GetTestID: AnsiString; override; |
83 |
|
begin |
84 |
|
if FIsChild then |
85 |
|
begin |
86 |
< |
writeln(FLogFile,'*Monitor* '+DateTimeToStr(EventTime)+' '+EventText); |
86 |
> |
writeln(FLogFile,'*Monitor* '{+DateTimeToStr(EventTime)}+' '+EventText); |
87 |
|
Flush(FLogFile); |
88 |
|
end; |
89 |
|
end; |
90 |
|
|
91 |
+ |
procedure TTest14.ShowStatistics(Sender: TObject); |
92 |
+ |
begin |
93 |
+ |
if ChildProcess then |
94 |
+ |
begin |
95 |
+ |
writeln(FLogFile,FIBSQLMonitor.ReadCount,' ISQL Monitor Messages Received'); |
96 |
+ |
Flush(FLogFile); |
97 |
+ |
Close(FLogFile); |
98 |
+ |
end; |
99 |
+ |
end; |
100 |
+ |
|
101 |
|
{$IFDEF UNIX} |
102 |
|
procedure DoSigTerm(sig : cint);cdecl; |
103 |
|
begin |
117 |
|
{$endif} |
118 |
|
if fpSigAction(SigTerm,Fna,Foa)<>0 then |
119 |
|
begin |
120 |
< |
writeln(OutFile,'Error setting signal handler: ',fpgeterrno,'.'); |
120 |
> |
writeln('Error setting signal handler: ',fpgeterrno,'.'); |
121 |
|
halt(1); |
122 |
|
end; |
123 |
|
end; |
126 |
|
procedure TTest14.CreateObjects(Application: TTestApplication); |
127 |
|
begin |
128 |
|
inherited CreateObjects(Application); |
129 |
< |
FIBSQLMonitor := TIBSQLMonitor.Create(Application); |
130 |
< |
FIBSQLMonitor.TraceFlags := [tfQPrepare, tfQExecute, tfQFetch, tfError, tfStmt, tfConnect, |
131 |
< |
tfTransact, tfBlob, tfService, tfMisc]; |
132 |
< |
IBDatabase.TraceFlags := [tfQPrepare, tfQExecute, tfQFetch, tfError, tfStmt, tfConnect, |
133 |
< |
tfTransact, tfBlob, tfService, tfMisc]; |
134 |
< |
FIBSQLMonitor.OnSQL := @HandleOnSQL; |
135 |
< |
FLog := TStringList.Create; |
136 |
< |
FProcess := TProcess.Create(Application); |
129 |
> |
if ChildProcess then |
130 |
> |
begin |
131 |
> |
FIBSQLMonitor := TIBSQLMonitor.Create(Application); |
132 |
> |
FIBSQLMonitor.TraceFlags := [tfQPrepare, tfQExecute, tfQFetch, tfError, tfStmt, tfConnect, |
133 |
> |
tfTransact, tfBlob, tfService, tfMisc]; |
134 |
> |
FIBSQLMonitor.OnSQL := @HandleOnSQL; |
135 |
> |
FIBSQLMonitor.OnMonitoringDisabled := @ShowStatistics; |
136 |
> |
end |
137 |
> |
else |
138 |
> |
begin |
139 |
> |
IBDatabase.TraceFlags := [tfQPrepare, tfQExecute, tfQFetch, tfError, tfStmt, tfConnect, |
140 |
> |
tfTransact, tfBlob, tfService, tfMisc]; |
141 |
> |
FLog := TStringList.Create; |
142 |
> |
FProcess := TProcess.Create(Application); |
143 |
> |
end; |
144 |
|
end; |
145 |
|
|
146 |
|
function TTest14.GetTestID: AnsiString; |
218 |
|
begin |
219 |
|
while not FTerminated do |
220 |
|
CheckSynchronize(1); //loop until terminated |
203 |
– |
Close(FLogFile); |
221 |
|
Exit; |
222 |
|
end; |
223 |
|
|
224 |
+ |
Sleep(1000); {wait for child to become ready} |
225 |
|
CheckSynchronize(1); |
226 |
|
with IBQuery do |
227 |
|
begin |
243 |
|
PrintDataSet(IBQuery); |
244 |
|
end; |
245 |
|
IBDatabase.Connected := false; |
246 |
+ |
Sleep(1000); |
247 |
|
CheckSynchronize(1); |
248 |
+ |
Sleep(1000); |
249 |
|
DisableMonitoring; |
250 |
+ |
writeln(Outfile,MonitorHook.GetWriteCount,' ISQL Monitor Messages written'); |
251 |
+ |
Sleep(1000); |
252 |
|
FProcess.Terminate(0); |
253 |
|
Sleep(1000); |
254 |
|
assignFile(aLogFile,LogFileName); |