Root > How to... > ...change EurekaLog's settings at run-time? > ...change leaks options?

...change leaks options?

Previous pageReturn to chapter overviewNext page   

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:




Send feedback... Build date: 2024-09-30
Last edited: 2023-03-07
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/how_to_change_leaks_options.php