Tracing in DnDns

Apr 25, 2012 at 9:02 AM

Hi,

First things first - I'd like to thank you all for this great library, I tried once to write something similar and I know how difficult it can be. TNX

Now, as a developer who thinks tracing is critical for any program (even my "Hello World" programs always start with Trace.Write...) I'd like to suggest a little improvement to the tracing issue in DnDns:

Currently, DnDns uses System.Diagnostics.Trace.WriteLine and System.Diagnostics.Trace.Assert to write trace messages (If I understand correctly). Although it's much better than other libraries and programs I've had the chance to look at but I think it can be problematic sometimes, for example, let's say I'm using a method of my own to write the trace information (this method eventually calls the System.Diagnostics.Trace.WriteLine or System.Web.Trace.Write but this method will format the message before writing it) if I choose to use DnDns in my project the trace messages will not have a consistent format. Another example, let's assume that I'd like to have some control over the verbosity of the trace messages written from my application, if I'm using DnDns I cannot decide that I want only some of the messages to be written. Another example would be the usage of DnDns in an ASP.Net project that uses only System.Web.Trace and for some reason doesn't like to use the System.Diagnostics.Trace, in such a scenario, no DnDns trace messages will appear on the trace.axd page.

I suggest that the DnDns will not call Trace.WriteLine at all, instead it will expose an event or even better, a series of events (OnTraceInfo, OnTraceWarning, OnTraceError) that the calling class can use to redirect the trace messages or to manipulate them in any way that is suitable to the developer that is using the DnDns library.

 

What do you think? Can it be done? Should it be done?

Yuval.