#1 2025-09-26 18:46:13

itSDS
Member
From: Germany
Registered: 2014-04-24
Posts: 583

Feature Request Logging

Hi Arnaud, i have a question / Feature for Logging.

Is it possible to Disable Logging for 1 Thread after calling function like DisableLog
Reason: I have recurring Function called by a Timer which do nothing if Query gives no result, but flod the log with "useless" stuff if they find something by Query i will Enable Log.

here a sample

function DoOnTimer;
begin
  TSynLog.DisableLog;
  if ....Orm.RetrieveListObjArray(list, TOrmQueue, 'Status=?', [ord(TOrmStatus.New)], '*') then begin
    TSynLog.EnableLog; // Enables Log
// Do something with logging enabled
    TSynLog.Enter('Data Found');
   
  end;
   
// Calls EnableLog on exit (Like Enter/Leave) if Log enabled does nothing :)
end;

Rad Studio 12.3 Athens / 13.0 Ganymede

Offline

#2 2025-09-29 14:13:52

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,226
Website

Re: Feature Request Logging

Can you create an issue with this?

Offline

#3 2025-10-03 08:51:28

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,226
Website

Re: Feature Request Logging

Ok, no issue created, but I implemented it anyway.
smile

https://github.com/synopse/mORMot2/commit/af2c5be68
core: new TSynLogFamily.DisableCurrentThread property
- allow to temporarly avoid logging in the current thread
- after setting true to this property, should eventually be reset to false
- won't affect exceptions logging, as one would expect for safety reasons

But you need to make your own eventual

 TSynLog.Family.DisableCurrentThread := true;
 try
 ...
 finally
   TSynLog.Family.DisableCurrentThread := false;
 end;

Offline

Board footer

Powered by FluxBB