[patch_done] TZSQLMonitor logs using WideChar on D2009?

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
skydvrz
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 15.12.2005, 22:56
Location: Olympia, WA USA
Contact:

[patch_done] TZSQLMonitor logs using WideChar on D2009?

Post by skydvrz »

My SQL debug log lines

L o o k s l i k e t h i s . a n d a r e v e r y h a r d t o r e a d!

:shock: There are also no valid CRLF end-of-lines in the text file, so all log lines are in one big hairy gob of nasty looking text.

I think the TZSQLMonitor.SaveToFile method needs to be "AnsiFied" for D2009 compilation, and viewing the resulting logs in Notepad or other simple text editors.

I played with the source and this seems to fix it:

{**
Saves the logging events to the specified file.
@param FileName a name of the file to write the events.
}
procedure TZSQLMonitor.SaveToFile(const FileName: string);
var
I: Integer;
Stream: TFileStream;
Temp: Ansistring;
Buffer: PAnsiChar;
begin
if not FileExists(FileName) then
Stream := TFileStream.Create(FileName, fmCreate)
else
Stream := TFileStream.Create(FileName, fmOpenWrite or fmShareDenyWrite);
try
for I := 0 to FTraceList.Count - 1 do
begin
Temp := TZLoggingEvent(FTraceList).AsString + #13#10;
Buffer := PAnsiChar(Temp);
Stream.Write(Buffer^, StrLen(Buffer) * sizeof(Ansichar));
end;
finally
Stream.Free;
end;
end;

{**
Handles a new incoming logging event.
@param Event an incoming logging event.
}
procedure TZSQLMonitor.LogEvent(Event: TZLoggingEvent);
var
LogTrace: Boolean;
Stream: TFileStream;
Temp: Ansistring;
Buffer: PAnsiChar;
begin
LogTrace := True;
DoTrace(Event, LogTrace);
if not LogTrace then Exit;

{ Store the event. }
if FMaxTraceCount <> 0 then
begin
if FMaxTraceCount > 0 then
TruncateTraceList(FMaxTraceCount - 1);
FTraceList.Add(TZLoggingEvent.Create(Event.Category, Event.Protocol,
Event.Message, Event.ErrorCode, Event.Error));
end;

{ Save the event. }
if FAutoSave and (FFileName <> '') then
begin
if not FileExists(FFileName) then
Stream := TFileStream.Create(FFileName, fmCreate)
else
Stream := TFileStream.Create(FFileName, fmOpenReadWrite or fmShareDenyWrite);
try
Stream.Seek(0, soFromEnd);
Temp := Event.AsString + #13#10;
Buffer := PAnsiChar(Temp);
Stream.Write(Buffer^, StrLen(Buffer)*sizeof(Ansichar));
finally
Stream.Free;
end;
end;

DoLogTrace(Event);
end;


Thanks!

Kevin G. McCoy
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Thanks. A quick test shows this also works for older compilers.
SVN Rev. 670

Mark
Image
skydvrz
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 15.12.2005, 22:56
Location: Olympia, WA USA
Contact:

Post by skydvrz »

Glad I could help. 7.0 Alpha is working pretty well for me on D2009 - when do you think it will go beta?

You still need to fix the memory leaks :-)
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

You
I hope you wanted to say 'We still need to fix the memory leaks'?

As I told people before : I can only do what I really know about. Memory leaks is just something that's very difficult for me.

About the beta thing... It's dfficult to tell. We have a very severe problem on D2009 with the posting of strings as parameters when the prepared statements are emulated (at least for mysql, but I think this problem exists for all emulating drivers, eg Postgresql)

So those Delphi guys deciding to make String different from AnsiString just about killed us.

Mark
Image
skydvrz
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 15.12.2005, 22:56
Location: Olympia, WA USA
Contact:

Post by skydvrz »

mdaems wrote:
You
I hope you wanted to say 'We still need to fix the memory leaks'?
:oops:

I'll look at it when I get a chance, but my first impression was that there are some fundamental design issues causing the leaks. Any fix would be fairly invasive and likely to break other stuff.

I'll try to devote some time to it, but I have 2 major projects going, where I am the sole programmer. I am a bit buried right now - not a bad place to be in this economy, but my schedule doesn't leave me much free time.

Other than some minor weirdness with strings (easily worked around for me), 7.0 is working fine in a couple of my large projects on MySQL.

Best regards,

Kevin G. McCoy
Locked