Root > How to... > ...determinate if EurekaLog is active or not?

...determinate if EurekaLog is active or not?

Previous pageReturn to chapter overviewNext page   

We recommend to use IFDEF-checks, for example:

 

{$IFDEF EUREKALOG}
uses
  EModules;
{$ENDIF}
 
{$IFDEF EUREKALOG}

// Compiled with EurekaLog
CurrentEurekaLogOptions. // ...
{$ENDIF}

 

Alternatively there are functions (in EBase unit) like:

 

function IsEurekaLogInstalled: Boolean;
function IsEurekaLogActive: Boolean;
function IsEurekaLogActiveInThread(const AThreadID: Cardinal = 0): Boolean;

 

EurekaLog is considered to be active (e.g. will do its work) only if all of the following are true:

EurekaLog was compiled in (EUREKALOG symbol was defined, EurekaLog's units were added, IsEurekaLogInstalled returns True);
EurekaLog is enabled globally (IsEurekaLogActive returns True);
EurekaLog is enabled in the current thread (IsEurekaLogActiveInThread returns True).

 

For example:

 

{$IFDEF EUREKALOG}
if IsEurekaLogActive and 
   IsEurekaLogActiveInThread then

  // EurekaLog is compiled in and is enabled
  raise Exception.Create('will be handled by EurekaLog')
else

  // EurekaLog is compiled in, but is disabled
  raise Exception.Create('will be handled by RTL/VCL');
{$ELSE}

// EurekaLog is not compiled in
raise Exception.Create('will be handled by RTL/VCL');
{$ENDIF}

 

Notes:

EBase unit can be included into any application - even without EurekaLog;
IsEurekaLogActive will return False when IsEurekaLogInstalled returns False, so it is usually not required to call IsEurekaLogInstalled.
By default, EurekaLog is enabled on startup for main thread only. You can enable EurekaLog for background threads.

 

You can also detect if EurekaLog was disabled during compilation by looking at output of your compilation:

 

 

IDE's Messages / Build window - this is output when EurekaLog is disabled

 

 

See also:




Send feedback... Build date: 2022-03-28
Last edited: 2022-01-17
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_detect_if_eurekalog_is_active.php