blikblum/multilog

Default value of Logger.ThreadSafe

Opened this issue · 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 (#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.

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