41 |
|
|
42 |
|
{$Mode Delphi} |
43 |
|
|
44 |
+ |
{$codepage UTF8} |
45 |
+ |
|
46 |
|
interface |
47 |
|
|
48 |
|
uses |
49 |
< |
LMessages, LCLIntf, LCLType, LCLProc, Forms, Controls, Dialogs, |
48 |
< |
IB, IBUtils, IBSQL, IBCustomDataSet, IBDatabase, IBServices, IBXConst,SysUtils, |
49 |
> |
IB, IBUtils, IBSQL, IBCustomDataSet, IBDatabase, IBServices, IBTypes ,SysUtils, |
50 |
|
Classes, |
51 |
|
{$IFDEF WINDOWS } |
52 |
|
Windows |
72 |
|
{$DEFINE HAS_SEMTIMEDOP} |
73 |
|
{$ENDIF} |
74 |
|
|
74 |
– |
const |
75 |
– |
WM_MIN_IBSQL_MONITOR = WM_USER; |
76 |
– |
WM_MAX_IBSQL_MONITOR = WM_USER + 512; |
77 |
– |
WM_IBSQL_SQL_EVENT = WM_MIN_IBSQL_MONITOR + 1; |
78 |
– |
|
75 |
|
type |
76 |
|
TIBCustomSQLMonitor = class; |
77 |
|
|
144 |
|
implementation |
145 |
|
|
146 |
|
uses |
147 |
< |
contnrs, syncobjs |
147 |
> |
contnrs, syncobjs, CustApp, FBMessages |
148 |
|
{$IFDEF USE_SV5_IPC} |
149 |
|
,ipc, Errors, baseunix |
154 |
– |
{$IF FPC_FULLVERSION <= 20402 } , initc {$ENDIF} |
150 |
|
{$ENDIF}; |
151 |
|
|
157 |
– |
{$IF FPC_FULLVERSION < 20600 }{$STATIC ON} {$ENDIF} |
152 |
|
|
153 |
|
const |
154 |
|
cMonitorHookSize = 1024; |
283 |
|
_MonitorHook: TIBSQLMonitorHook; |
284 |
|
bDone: Boolean; |
285 |
|
CS : TCriticalSection; |
286 |
+ |
|
287 |
+ |
const |
288 |
+ |
ApplicationTitle: string = 'Unknown'; |
289 |
|
|
290 |
|
{ TIBCustomSQLMonitor } |
291 |
|
|
292 |
|
constructor TIBCustomSQLMonitor.Create(AOwner: TComponent); |
293 |
+ |
var aParent: TComponent; |
294 |
|
begin |
295 |
|
inherited Create(AOwner); |
296 |
|
FTraceFlags := [tfqPrepare .. tfMisc]; |
297 |
|
if not (csDesigning in ComponentState) then |
298 |
|
begin |
299 |
+ |
aParent := AOwner; |
300 |
+ |
while aParent <> nil do |
301 |
+ |
begin |
302 |
+ |
if aParent is TCustomApplication then |
303 |
+ |
begin |
304 |
+ |
ApplicationTitle := TCustomApplication(aParent).Title; |
305 |
+ |
break; |
306 |
+ |
end; |
307 |
+ |
aParent := aParent.Owner; |
308 |
+ |
end; |
309 |
|
MonitorHook.RegisterMonitor(self); |
310 |
|
end; |
311 |
|
FEnabled := true; |
340 |
|
(st.FDataType in FTraceFlags) then |
341 |
|
FOnSQLEvent(st.FMsg, st.FTimeStamp); |
342 |
|
st.Free; |
335 |
– |
{$IFDEF WINDOWS} |
336 |
– |
Application.ProcessMessages |
337 |
– |
{$ENDIF} |
343 |
|
end; |
344 |
|
|
345 |
|
procedure TIBCustomSQLMonitor.SetEnabled(const Value: Boolean); |
530 |
|
else |
531 |
|
st := qry.Name; |
532 |
|
st := st + ': [Execute] ' + qry.SQL.Text; {do not localize} |
533 |
< |
if qry.Params.Count > 0 then begin |
534 |
< |
for i := 0 to qry.Params.Count - 1 do begin |
533 |
> |
if qry.Params.GetCount > 0 then begin |
534 |
> |
for i := 0 to qry.Params.GetCount - 1 do begin |
535 |
|
st := st + CRLF + ' ' + qry.Params[i].Name + ' = '; |
536 |
|
try |
537 |
|
if qry.Params[i].IsNull then |
707 |
|
{$IFDEF DEBUG}writeln('Write SQL Data: '+Text);{$ENDIF} |
708 |
|
if not assigned(FGlobalInterface) then |
709 |
|
FGlobalInterface := TGlobalInterface.Create; |
710 |
< |
Text := CRLF + '[Application: ' + Application.Title + ']' + CRLF + Text; {do not localize} |
710 |
> |
Text := CRLF + '[Application: ' + ApplicationTitle + ']' + CRLF + Text; {do not localize} |
711 |
|
if not Assigned(FWriterThread) then |
712 |
|
FWriterThread := TWriterThread.Create(FGLobalInterface); |
713 |
|
FWriterThread.WriteSQLData(Text, DataType); |
1102 |
|
if FpGetEnv('FBSQL_IPCFILENAME') <> nil then |
1103 |
|
IPCFileName := strpas(FpGetEnv('FBSQL_IPCFILENAME')) |
1104 |
|
else |
1105 |
< |
IPCFileName := '/tmp/' + IPCFileName + '.' + strpas(FpGetEnv('USER')); |
1105 |
> |
IPCFileName := GetTempDir(true) + IPCFileName + '.' + strpas(FpGetEnv('USER')); |
1106 |
|
{$ENDIF} |
1107 |
|
|
1108 |
|
finalization |