Root > Customizing EurekaLog > Coding > Changing options at run-time

Changing options at run-time

Previous pageReturn to chapter overviewNext page   

One of the simplest customizations is changing EurekaLog options from the code. ExceptionLog7 unit declares global function CurrentEurekaLogOptions. This function returns TEurekaModuleOptions class (which is declared in EClasses unit), which contains properties corresponding to EurekaLog's options. I.e. almost each property (that you can change in EurekaLog project options dialog) is presented as property in TEurekaModuleOptions class.

 

For example, you may write a program which is able to work either as Win32 service or as GUI front end - depending on the way it was launched. You probably want to have different bug reports for each of this mode. And Win32 service can't have visual error dialogs. Obviously, this can't be solved by setting options at design-time, since trigger event happens at run-time. So, you setup common options at design time and write such code, which sets the differences:

 

uses
  ETypes, EClasses, ExceptionLog7;
 
...
 
initialization
 
  if IsWin32Service then // <- this is your own routine
  begin
    CurrentEurekaLogOptions.OutputPath := '%APPDATA%\MySoftware\Win32Service\';
    CurrentEurekaLogOptions.ExceptionDialogType := edtService;
  end
  else
  begin
    CurrentEurekaLogOptions.OutputPath := '%APPDATA%\MySoftware\GUIFrontEnd\';
    CurrentEurekaLogOptions.ExceptionDialogType := edtMSClassic;
  end;
 
end.

 

Notes:

Some options (such as build options) affects compilation stage. Thus, they can't be changed at run-time when file was already compiled.
Some options (such as leaks control) requires special rules for setting up. That's why they are controlled with other means, not with options class. However, 90% of options can be freely changed via this class.
Needless to say that you may use environment variables and exception filters from code too. You can alter exception filters via CurrentEurekaLogOptions.ExceptionsFilters property.

 

Important note: ensure that features specified by your code will be available at run-time. For example, if your application uses MS Classic-styled exception dialog by default and you want to switch to EurekaLog-styled dialog with your code - then be sure to include code for EurekaLog dialog into your application. The same is true for send engines. Hooks and debug information providers are registered on startup and could not be customized at run-time.

 

CurrentEurekaLogOptions is a global function which contains default options for your application in run-time. It affects all exceptions and all threads. Typically, you alter these options at startup (either in initialization section of some unit or in begin/end of .dpr file).

 

Often there is need to alter option only for some exceptions. EurekaLog provides additional feature for this: events and event hanlders.

 

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.

 

 

See also:




Send feedback... Build date: 2023-09-11
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/customizing_options_runtime.php