Reputation: 25
I am using Madexcept tool to log the exceptions, but I am not able to log the call stack in periodically. Can any one suggest me how to log the call stack.
Upvotes: 2
Views: 1696
Reputation: 15817
To get just the trace without the whole report (which slows it down), you can just call MadStackTrace. It's very handy when you want to know how your program is getting into various procedures/functions/methods, expecially when there are multiple ways it can happen, or you're scratching your head over performance problems.
You'll need this in your Uses:
uses
MadStackTrace;
// Then to use the thing:
procedure foo;
begin
writeln('How I got to FOO:' + MadStackTrace.StackTrace);
end;
http://help.madshi.net/madStackTraceUnit.htm
Upvotes: 4
Reputation: 612934
The naive answer to your question is that you can do the following, inside a dedicated thread:
var
exc: IMEException;
....
exc := madExcept.NewException;
Logger.Log(exc.BugReport);
Note that this logs the entire bug report. If you want to log less information, you can use the normal madExcept techniques to extract that information from the IMEException
reference.
Also be warned that gathering all this information takes a significant amount of time, and will interfere with the execution of your program. It seems to me that what you really want is a profiler, or some trace logging. I don't think that madExcept is actually the solution to your underlying problem.
Upvotes: 1