Hello,

Since I'm continuing to write software in D (no, nothing special...just pet projects) I felt that I needed to create a library to handle logging to a file. I have a good start and it seems to work pretty well. I even have a couple ideas left to implement to make it better, however I'm having trouble with one. One thing that I did implement, which I think is pretty cool, is a set up the class to start a thread as a daemon to run in the background and check for updates to the config file, much like log4j. This way the user can change the log level at runtime.

One thing I'm thinking that I want to do is have the writing to the logfile handled by a separate class. This way I'm hoping to ensure that there's not a lot of unnecessary synchronizing going on and the amount of work writing to the logfile won't slow down the rest of the program. My question is, what is the best approach?

1) I use the current core.thread library and put all my messages in a buffer that the thread checks periodically, pulls off a new message, and then writes it to a file. There will be some work to make sure nothing collides with each other, but I think I can manage it.

2) I wait for the new threading library with message passing to come out and just rely on the message passing to handle everything. It's a much cleaner approach based on my experience with Erlang, but there are two issues and the major one is I have no idea when it'll be ready. Granted, I don't need this capability now, but I'm interested in getting it to work.

3) Something else. I really don't have much experience with threading, so I'm being very careful and really want to understand it. This library looks to be a good way to learn, however if it's not the best way to do things, then what would be?

Thanks in advance for any input.

Casey

Reply via email to