multilog icon indicating copy to clipboard operation
multilog copied to clipboard

Default value of Logger.ThreadSafe

Open zeljkoavramovic opened this issue 7 years ago • 1 comments

I would prefer default value for Logger.ThreadSafe property to be true, or even beter to delete it and use multi thread detection. Something like this that I have used in SafeLogger unit (https://github.com/blikblum/multilog/issues/2):

procedure LogLock;
begin
  if IsMultiThread then // no need for locking if the only thread in application is the main thread
    Guardian.Enter;
end;

procedure LogUnlock;
begin
  if IsMultiThread then // no need for locking if the only thread in application is the main thread
    Guardian.Leave;
end; 

https://www.freepascal.org/docs-html/rtl/system/ismultithread.html

If Logger.ThreadSafe is not set to true and multiple threads use FileChannel, then EInOutError exception will be raised and users might think that it's Multilog fault.

zeljkoavramovic avatar Dec 06 '17 13:12 zeljkoavramovic

I updated the repository with automatic threadsafe. Will not bump version for now. Please test if possible with multi threaded if possible

blikblum avatar Jan 17 '22 21:01 blikblum