Creating a logging library and have questions

Rainer Deyke rainerd at eldwood.com
Tue Feb 2 21:03:19 PST 2010


sybrandy wrote:
> 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.

Wouldn't this allow logging messages to be lost before a hard crash?  To
me, that would greatly reduce the utility of the logging system.

> 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?

Global mutex associated with the logging system.  Lock, output, unlock.
 There are scalability issues with that approach, but I don't see why it
wouldn't work in this situation.  (Plus, if you have a message queue,
you probably need to protect that queue with a mutex anyway.)


-- 
Rainer Deyke - rainerd at eldwood.com


More information about the Digitalmars-d-learn mailing list