You will have to protect your writing to file with thread synchronization.

We do the exact same thing in the tiOPF2 project.  You can look at the
code to help with your implementation, or adapt the tiOPF2 code to you
liking. The units you might be interested in are tiLog.pas and
tiLogToFile.pas

We implemented a cached logging (used in File and GUI logging), so it
doesn't slow down the application, because it doesn't need to write
that frequent to the file or GUI.  Logging to the Console is not
cached and has no issues with multithreading.

Funny enough, we have just fixed some multithreading issues with the
LogToFile and LogToGUI. It now works perfectly under Linux and
Windows.

[ tiLog.pas ]
http://svn.sourceforge.net/viewvc/tiopf/tiOPF2/Trunk/Core/tiLog.pas?view=markup

[ tiLogToFile.pas ]
http://svn.sourceforge.net/viewvc/tiopf/tiOPF2/Trunk/Core/tiLogToFile.pas?view=markup


Graeme.



On 6/1/07, Alvise Nicoletti <[EMAIL PROTECTED]> wrote:
Thank you for the code example, I putted into an unit and, after some
editing, I managed to compile a hello world global usable method.

Now i'll try it with the right class (a global logger with a .write()
method) my only fear is about the concurrence on the text file, due to
multithreading reasons, however I think it will work without problems on
linux.

I'll try that pattern with a mysql resource too, but I think that's a
lot more risky.


_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to