Root > How to... > ...enable/disable EurekaLog? > ...enable/disable EurekaLog at run-time?

...enable/disable EurekaLog at run-time?

Previous pageReturn to chapter overviewNext page   

Disabling EurekaLog means that EurekaLog will be inactive; in other words: hooks will call default implementations (from RTL/VCL). Your application will behave like EurekaLog was not installed. By default, EurekaLog is enabled on startup for main thread only. You can enable EurekaLog for background threads.

 

 

Disable EurekaLog at run-time

Call

SetEurekaLogState(False);

to disable EurekaLog for the entire application. Or call

SetEurekaLogStateInThread(0, False);

to disable EurekaLog in current thread only.

 

Both functions are from the EBase unit.

 

You can also call the

DisableMemLeaksRegistering;

to disable memory leaks only.

 

This function is from the EMemLeaks unit.

 

 

Enable EurekaLog at run-time

Call

SetEurekaLogState(True);

to enable EurekaLog for the entire application (which is a default). Or call

SetEurekaLogStateInThread(0, True);

to enable EurekaLog in current thread only (default for main thread only).

 

Both functions are from the EBase unit.

 

You can also call the

EnableMemLeaksRegistering;

to enable memory leaks back after disabling.

 

This function is from the EMemLeaks unit.

 

Note: EurekaLog is considered to be active (in other words: will do its work) only if all of the following are true:

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

 

Therefore, if you want 100% guarantee that EurekaLog will be enabled - you need to call both SetEurekaLogState(True); and SetEurekaLogStateInThread(0, True); However, on practice: you will be more likely to call just one function - the opposite of what you have called earlier. For example, if you have called SetEurekaLogState(False); earlier - then you need to call just SetEurekaLogState(True);

 

Few examples:

 

SetEurekaLogStateInThread(0, False);
try
  Result := StrToInt({ ... });
except
  Result := 0;
end;

SetEurekaLogStateInThread(0, True);

 

or:

 

function ThreadFunc(Parameter: Pointer): Integer;
begin
  try

    NameThread('This is my thread');

    SetEurekaLogStateInThread(0, True); 
 

    // ... your normal code for the thread ...

 
    Result := 0; 
  except
    ApplicationHandleException(nil); 
    Result := 1; 
  end;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
var
  TID: Cardinal;
begin
  CloseHandle(BeginThread(nil, 0, ThreadFunc, nil, 0, TID));
end;

 

 

See also:




Send feedback... Build date: 2023-09-11
Last edited: 2023-08-09
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_enable_disable_eurekalog_runtime.php