EurekaLog
Menu

EurekaLog 7 Manual

...change EurekaLog's settings at run-time?

EurekaLog options are represented by TEurekaModuleOptions class from EClasses unit.

Note: description of almost every option contains name of corresponding property of TEurekaModuleOptions class. For example:

1. "Save bug report to file" (.SaveLogFile) option enables saving...

This means that you can change this option at run-time by altering the .SaveLogFile property of TEurekaModuleOptions instance (see below).

If there is no mention of corresponding property - this means that:

  • this option can not be changed at run-time:
    • option affects only compilation - for example, stripping relocation tables, or encrypting injecting debug information;
    • option can not be changed after initial setup - for example, using low-level hooks, or installing memory manager filter to catch leaks;
  • option is changed by other means (for example, leaks and memory options are changed by routines in EMemLeaks unit; hang detection options are changed by routines in EFreeze unit).

Option 1

Assuming you have EurekaLog's exception information object (e.g. inside event handler) - you can use the .Options property:

procedure MyHandler(const ACustom: Pointer;
  AExceptionInfo: TEurekaExceptionInfo;
  var AHandle: Boolean;
  var ACallNextHandler: Boolean);

// ... 

AExceptionInfo.Options.SaveLogFile := False;

Option 2

Global options are returned by the CurrentEurekaLogOptions function from the EModules unit:

uses
  EModules; // for CurrentEurekaLogOptions

CurrentEurekaLogOptions.SaveLogFile := False;

Important Note: altering global options will not affect options of already raised exceptions. If you want to change options for a particular exception - obtain EurekaLog's exception information object for that exception and use .Options property (as shown in "option 1" above). E.g.:

uses
  EEvents,           // for RegisterEventExceptionNotify
  EException,        // for TEurekaExceptionInfo  
  ETypes,            // for edtNone
  EExceptionManager; // for ExceptionManager

procedure DoSomething;
begin
  try
    // your code here
  except
    on E: Exception do
    begin
      // WRONG: Changing global options instead of options for E
      CurrentEurekaLogOptions.ExceptionDialogType := edtNone; // <- this is wrong!

      // CORRECT: Changing options for E
      ExceptionManager.Info(E).Options.ExceptionDialogType := edtNone; // <- correct!
      // See also

      Application.HandleException(nil); 
    end;
  end;
end;

procedure MyExceptionNotifyHandler(const ACustom: Pointer; 
  AExceptionInfo: TEurekaExceptionInfo; 
  var AHandle: Boolean; 
  var ACallNextHandler: Boolean);
begin
  // WRONG: Changing global options instead of current exception's options 
  CurrentEurekaLogOptions.SaveLogFile := False; // <- this is wrong!

  // CORRECT: Changing current exception's options 
  AExceptionInfo.Options.SaveLogFile := False;  // <- correct!
end;

initialization
  // CORRECT: Changing global options
  CurrentEurekaLogOptions.SaveLogFile := True; // <- correct!

  // WRONG: There is no exception here, impossible to change exception's options
  AExceptionInfo.Options.SaveLogFile := True;  // <- this is wrong!

  RegisterEventExceptionNotify(nil, MyExceptionNotifyHandler);
end.

See also: