AlignedTextWriterTraceListener ClassCleanCode C# Libraries v1.2.03 API
Directs tracing or debugging output to a OnlineTextWriter or to a OnlineStream, formatted such that the message indents but all other attributes are always vertically aligned.
Inheritance Hierarchy

OnlineSystem Object
  OnlineSystem MarshalByRefObject
    OnlineSystem.Diagnostics TraceListener
      OnlineSystem.Diagnostics TextWriterTraceListener
        CleanCode.Diagnostics AlignedTextWriterTraceListener

Namespace: CleanCode.Diagnostics
Assembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
Syntax

public class AlignedTextWriterTraceListener : TextWriterTraceListener, 
	ITraceListenerIndenter
Remarks

Like the OnlineDelimitedListTraceListener, OnlineXmlWriterTraceListener, and OnlineConsoleTraceListener, this class derives from OnlineTextWriterTraceListener 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 OnlineTraceOptions, 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 -- OnlineExploring Secrets of .NET Diagnostics -- available on the DevX online magazine.

Since CleanCode 0.9.20.

See Also