Inspired by our recent article about using EurekaLog together with SmartInspect, SmartInspect user Jeremy Brown ported our example to madExcept and kindly provided us with screenshots and sample code.
The example project demonstrates how to attach an event handler to madExcept and add a SmartInspect log file to madExept’s crash report whenever an unhandled exception occurs:
uses
madExcept;
// [...]
procedure ExceptionHandler(const ExceptIntf: IMEException;
var Handled: Boolean);
const
ZIPFILE = 'CrashReport.zip';
var
LStream : TFileStream;
LTempPath : array[0..MAX_PATH+1] of Char;
LFileName : String;
begin
Handled := False;
{ Get a temporary filename }
if GetTempPath(MAX_PATH, LTempPath) = 0 then
Exit;
// Save madShi's bug report information in the log.
SiMain.LogException(Exception(ExceptIntf.ExceptObject),
'Madshi Exception Handler');
SiMain.LogString('BugReport', ExceptIntf.BugReport);
ExceptIntf.AdditionalAttachments.Clear;
{ Put everything in a zip file }
ExceptIntf.ScreenShotZip := ZIPFILE;
ExceptIntf.BugReportZip := ZIPFILE;
{ Just some extra optional information }
ExceptIntf.AdditionalFields.Add('Application',
Application.Title);
LFileName := IncludeTrailingPathDelimiter(LTempPath) +
'CrashLog.sil';
{ Save the log file }
LStream := TFileStream.Create(LFileName, fmCreate);
try
Si.Dispatch('mem', 0, LStream);
finally
LStream.Free;
end;
{ Attach the file to madShi's crash report }
ExceptIntf.AdditionalAttachments.Add(LFileName, '', ZIPFILE);
end;
initialization
RegisterExceptionHandler(ExceptionHandler,
stTrySyncCallOnSuccess);
end.
The resulting madExcept email and crash report zip file includes a SmartInspect log file with the recent user actions and application data, along with madExcept’s error report and screenshot:

If you are already using madExcept and are planning to integrate it with SmartInspect (or the other way around), Jeremy’s example code is a great starting point and should get you up and running in a few minutes. You can download the example code here and learn more about the used techniques in the related EurekaLog article.





One Trackback
[...] like the application name and version number. Since we use SmartInspect we add this log file (here is another example of this) to the report as well as another log generated by our burning engine. SmartInspect-Logging in [...]