From a3f6697ffb872f553572627c73261cdd1ce55b67 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 21 Jan 2005 01:03:55 +0000 Subject: Initial checkin --- Debug.cs | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Debug.cs (limited to 'Debug.cs') 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; + + + /// + /// Simple debugging class + /// + /// + /// created by - ianc + /// created on - 06/09/2003 00:31:08 + /// + public class Debug + { + /// + /// Function to recieve debug output if requested + /// + public delegate void DebugEvent(string debug); + + /// + /// Enable/Disable debug console output + /// + public static bool Enable + { + get {return m_debug;} + set {m_debug=value;} + } + + /// + /// Event to capure debug + /// + public static event DebugEvent m_event; + + /// + /// Output debug text + /// + 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() + { + } + } +} -- cgit v1.2.3