Tracing in Release mode

Jul 18, 2014 at 6:34 AM
Edited Jul 18, 2014 at 7:10 AM
I used same tracing mechanism in my M2Mqtt project because I think it is good but there is a lack.
My project is distribuited also on Nuget and in that case I compile library with Release configuration. As you know in this configuration, the DEBUG symbol isn't defined. It means that the people who use my library from Nuget can't use tracing. Even if they define a TraceListener, the override ToString() method of message classes just calls base.ToString() so it shows the name type !
In my library I modified in the following way :
  • the tracing is related to TRACE symbol and not DEBUG symbol. TRACE symbol is also defined in Release configuration;
  • I wrap any call inside library to the Trace.WriteLine inside an #ifdef TRACE;
With first change I can guarateed that tracing also works in Release mode (so with Nuget library) when the user assigns a TraceListener. However, it means that if user doesn't define a TraceListener, the Trace.WriteLine is still called and it can causes performance problem. In this case, the user can download source code library (instead Nuget library) and disable TRACE symbol in Release configuration.

I also modified in my library from GetDebugString() to GetTraceString() ... it is more precise to talk about tracing and not debugging ;-)

Could be a good changes also for AMQP.Net Lite library ?

Jul 28, 2014 at 4:35 AM
I can see the need of tracing in release build, so I took your idea and used TRACE symbol to enable/disable tracing too.
Jul 28, 2014 at 6:07 AM
It was very useful to me !
Great to know that it will be also in AMQP.Net Lite library ;-)