blikblum / multilog

16 stars 9 forks source link

Default value of Logger.ThreadSafe #11

Open zeljkoavramovic opened 6 years ago

zeljkoavramovic commented 6 years ago

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.

blikblum commented 2 years ago

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