#1 Re: mORMot 1 » TSynLog automatic handling exceptions and SafeLoadLibrary problem » 2017-06-23 09:52:38

Hi,
I think TSynlog is a wonderful tools . So we are trying to use TSynlog but it seems we have the same problem when we load dynamically a DLL.
Do you have a solution ?
Thanks

#2 mORMot 1 » TSynLog - Exception - Don't get the Unit Name / Line Number » 2016-07-13 17:14:02

FasBelgium
Replies: 2

Hi,

I'm trying to use TSynLog to log exceptions, but in one case I don't receive the line number where the exception is occured.
Here's my test :

procedure TForm1.BtoSynLogExceptionClick(Sender: TObject);
var
  dummy    : Integer;
  dummyObj : TObject;
  ILog     : ISynLog;

begin
     with TSQLLog.Family do
     begin
         Level := [sllInfo..sllMonitoring];
         OnArchive := EventArchiveSynLZ;
     end;
     ILog := TSQLLog.Enter(Self); // => 16:48:33    Enter     TForm1(0341F010).00729B64 UFlexiForm.TForm1.BtoSynLogExceptionClick (373)

     dummy := 0;
     dummyObj := Nil;
     try
        if Round(5 div dummy) = 0 then; //OK - we get the Line number //=> 16:48:33    Exception OS        EDivByZero (C0000094) at 00729B87 UFlexiForm.TForm1.BtoSynLogExceptionClick (378)  stack trace API 005C4945 .....
     except
     end;
     Try
        if Round(5/dummy) = 0 then;   //KO - we don't get the Line number // => 16:48:33    Exception OS        EZeroDivide (C000008E) at 004079CF System.@ROUND (10039)  stack trace API 005C4945 Vcl.Controls.TCont .... 
     except
     End;
     Try
        TForm(dummyObj).ClassName; //OK - we get the Line number // => 16:48:33    Exception OS        EAccessViolation (C0000005) at 00729BFD   UFlexiForm.TForm1.BtoSynLogExceptionClick (386) stack trace API 00 ....
     except
     End;
     ILog.Log(sllInfo,'EndLog');
end;

Why "Round(5/dummy) = 0" don't get the Unit Name and the Line number when the Exception occured ?

Thanks for your help

Board footer

Powered by FluxBB