diff options
author | Ian C <ianc@noddybox.co.uk> | 2005-01-21 01:03:55 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2005-01-21 01:03:55 +0000 |
commit | a3f6697ffb872f553572627c73261cdd1ce55b67 (patch) | |
tree | 613f2a81953097c6a70e91b0ebbc09108156b91b /Debug.cs | |
parent | fe145c07172128b03f74d377761f33c2af4de960 (diff) |
Initial checkin
Diffstat (limited to 'Debug.cs')
-rw-r--r-- | Debug.cs | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/Debug.cs b/Debug.cs new file mode 100644 index 0000000..0bec821 --- /dev/null +++ b/Debug.cs @@ -0,0 +1,77 @@ +// Noddybox.Net - Provides simple server interaction classes +// Copyright (C) 2003 Ian Cowburn +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// $Id$ +// +namespace Noddybox.Net +{ + using System; + + + /// <summary> + /// Simple debugging class + /// </summary> + /// <remarks> + /// created by - ianc + /// created on - 06/09/2003 00:31:08 + /// </remarks> + public class Debug + { + /// <summary> + /// Function to recieve debug output if requested + /// </summary> + public delegate void DebugEvent(string debug); + + /// <summary> + /// Enable/Disable debug console output + /// </summary> + public static bool Enable + { + get {return m_debug;} + set {m_debug=value;} + } + + /// <summary> + /// Event to capure debug + /// </summary> + public static event DebugEvent m_event; + + /// <summary> + /// Output debug text + /// </summary> + public static void Out(System.Object o, string s) + { + string debug="DEBUG: " + o.ToString() + ": " +s; + + if (m_debug) + { + Console.WriteLine(debug); + } + + if (m_event!=null) + { + m_event(s); + } + } + + static private bool m_debug=false; + + private Debug() + { + } + } +} |