





CleanCode.Diagnostics AlignedTextWriterTraceListener
Namespace: CleanCode.Diagnostics
Assembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
public class AlignedTextWriterTraceListener : TextWriterTraceListener, ITraceListenerIndenter
Like the DelimitedListTraceListener,
XmlWriterTraceListener,
and
ConsoleTraceListener, this class derives
from
TextWriterTraceListener and can thus write to files or streams.
The primary distinction of this TraceListener is that it always uses a single line
of output per trace event; it guarantees all output options are always
aligned vertically, with only the message inheriting the indentation level;
and it makes indentation global across any instances of the class.
This gives a more intuitive picture of the program structure
when reviewing a lengthy log file.
Furthermore, you have more control over output options: besides the ones
selectable in
TraceOptions, there are several others
that are always emitted by other TraceListeners which you may turn off in this listener
by setting their corresponding length properties to zero.
These length properties serve to define a strict field width; if a value is larger,
even if it is an integer, it is trimmed to fit your specified field width.
There are four methods to output tracing events: TraceEvent, TraceInformation, TraceData, and TraceTransfer. The AlignedTextWriterTraceListener overrides only TraceEvent and TraceInformation at this time.
Besides the description here, I have also published
an article discussing the practical uses of this TraceListener --
Exploring Secrets of .NET Diagnostics
-- available on the DevX online magazine.
Since CleanCode 0.9.20.