Demonstrate indenting debug messages : Debug Trace : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Debug Trace »

 

Demonstrate indenting debug messages








    

/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa

Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/

// Indent.cs -- Demonstrate indenting debug messages.
//
//              Compile this program with the following command line:
//                  C:>csc /debug:full /d:DEBUG Indent.cs
using System;
using System.Diagnostics;

namespace nsDebugging
{
    public class Indent
    {
        static public void Main ()
        {
            Debug.Listeners.Clear ();
            Debug.Listeners.Add (new TextWriterTraceListener(Console.Out));
            Debug.AutoFlush = true;
            Debug.IndentSize = 5;
            Debug.WriteLine ("First level debug message.");
            Debug.Fail ("It failed!");
            FirstMethod ();
            Debug.WriteLine ("Return to first level debug message.");
        }
        static private void FirstMethod ()
        {
 //           Debug.Indent ();
            ++Debug.IndentLevel;
            Debug.WriteLine ("Second level debug message");
            SecondMethod ();
            Debug.WriteLine ("Return to second level debug message");
//            Debug.Unindent ();
            --Debug.IndentLevel;
        }
        static private void SecondMethod ()
        {
            Debug.Indent ();
            Debug.WriteLine ("Third level debug message.");
            Debug.Unindent  ();
        }
    }
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Debug Trace