#1 2016-07-13 17:14:02

FasBelgium
Member
Registered: 2016-07-13
Posts: 2

TSynLog - Exception - Don't get the Unit Name / Line Number

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

Offline

#2 2016-07-14 08:13:20

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: TSynLog - Exception - Don't get the Unit Name / Line Number

Sounds like a limitation about the strack trace mechanism in this context.

Try with the OS stack trace API instead.

Offline

#3 2016-07-25 19:26:33

brufreitas
Member
Registered: 2016-07-25
Posts: 1

Re: TSynLog - Exception - Don't get the Unit Name / Line Number

ab wrote:

Sounds like a limitation about the strack trace mechanism in this context.

Try with the OS stack trace API instead.


Hi AB.

I really don't understand your answer. Do you mind explaining it better? I have the same problem FasBelgium had and I'm really interested in this topic.

By the way, I've set the option above, whithout success:

TSynLog.Family.StackTraceUse := stOnlyAPI

Thank you very much.

Br Freitas.

Offline

Board footer

Powered by FluxBB