LockingLog

LockingLog is an implementation of Log that decorates instances of Log with locking semantics. This way Log implementations do not have to worry about implementing locking semantics themselves if they do not want to.

LockingLog does not wait infinitely for the lock to become available. It will wait up to a maximum of 5 minutes, which is user configurable with a constructor parameter. If the lock cannot be acquired in the time allotted, the message will NOT be logged out. A warning will be traced out. Standard trace listeners will be notified.

Examples

StringWriter globalBuffer = new StringWriter();

// use the default 2 minute wait
Log log = new LockingLog(new TextWriterLog(globalBuffer, TextWriterResponsibility.DoesNotOwn));

// use a custom 30 second wait
Log log = new LockingLog(new TextWriterLog(globalBuffer, TextWriterResponsibility.DoesNotOwn), TimeSpan.FromSeconds(30.0));

Last edited Feb 12, 2009 at 8:12 PM by justrudd, version 1

Comments

No comments yet.