EurekaLog
Menu

EurekaLog 7 Manual

...change leaks options?

Sometimes you want leaks checks to have different settings from normal exceptions. For example, you may want to disable visual dialog, so end user will not see a "crash" error in your application on shutdown, but you still want to get report, so you enable bug report file, and perhaps even automate sending.

The idea is that you need to run your customization code right before leaks checking will take place. You can do this with this code:

uses
  EMemLeaks, // for IsMemLeaksEnabled
  EModules,  // for CurrentEurekaLogOptions
  ETypes;    // for MemLeaksBeginCheck

var
  // This is saved low-level event handler
  EurekaLogMemLeaksBeginCheck: procedure;

// Your customization code
// It will be called right before leaks checking
procedure CustomizeLeaksChecking;
begin
  // IMPORTANT: call EurekaLog's implementation before your own code
  // This will initialize leaks checking with default/configured values
  // It is not required if you will call your code from a later stage
  // E.g. MemLeaksAddLeak or MemLeaksShow
  if Assigned(EurekaLogMemLeaksBeginCheck) then
    EurekaLogMemLeaksBeginCheck;
  // IMPORTANT: indicate that we are goind to perform more work,
  // so global variables (like CurrentEurekaLogOptions) should be restored
  // It is not required if you will call your code from a later stage
  // E.g. MemLeaksAddLeak or MemLeaksShow
  ETypes.Exiting := False;


  // Place your own code customizations below 
  // (code below is just an example, replace it with your own code):

  // Disable all visual dialogs
  CurrentEurekaLogOptions.ExceptionDialogType := edtNone;
  CurrentEurekaLogOptions.sndShowSendDialog := False;
  CurrentEurekaLogOptions.sndShowSuccessMsg := False;
  CurrentEurekaLogOptions.sndShowSuccessBugClosedOnlyMsg := False;
  CurrentEurekaLogOptions.sndShowFailureMsg := False;

  // Produce .el report file
  CurrentEurekaLogOptions.SaveLogFile := True;

  // Specify folder (must end with '\'), or file name for leaks
  CurrentEurekaLogOptions.OutputPath := '%APPDATA%\YourApp\Leaks.el';

  // Specify sending options: first bug tracker, if it fails - Simple MAPI
  CurrentEurekaLogOptions.SenderClasses := '';
  CurrentEurekaLogOptions.AddSenderClass(wsmExceptionless);
  CurrentEurekaLogOptions.AddSenderClass(esmSimpleMAPI);

  // Indicate that sending must be performed automatically
  CurrentEurekaLogOptions.edoSendErrorReportChecked := True;
  CurrentEurekaLogOptions.edoRestartChecked := False;
  CurrentEurekaLogOptions.edoMandatoryEMail := False;
  CurrentEurekaLogOptions.edoAttachScreenshotChecked := False;
  CurrentEurekaLogOptions.sndScreenshot := ssNone;

  // Configure send method
  // For example, you can change category to "Leaks", or add tags 
  // Available options depends on send method that you are using
  CurrentEurekaLogOptions.SendXYZ := ...;
end;

initialization
  // Do nothing

finalization
  // Ask EurekaLog to call us
  // when leaks checks are enabled
  if IsMemLeaksEnabled then
  begin
    EurekaLogMemLeaksBeginCheck := MemLeaksBeginCheck;
    MemLeaksBeginCheck := CustomizeLeaksChecking;
  end;
end.

See also: