debug.h

00001 // --*-c++-*-- 00002 /* 00003 $Id: debug_8h-source.html,v 1.1 2004/10/05 21:12:01 mentat Exp $ 00004 00005 GNU Messenger - The secure instant messenger 00006 Copyright (C) 2002 Jesse Lovelace - jllovela@eos.ncsu.edu 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 00022 */ 00023 #ifndef GM_DEBUG_H 00024 #define GM_DEBUG_H 00025 00026 #include <string> 00027 #include <iostream> 00028 #include <fstream> 00029 #include <memory> 00030 #include <sstream> 00031 00032 #include "gm/log.h" 00033 00034 namespace GNUMessenger 00035 { 00036 using namespace std; 00037 00038 #if defined(WIN32) && defined (_DEBUG) && defined (_MSC_VER) 00039 #pragma warning(disable: 4786 4290) 00040 #endif 00046 template<class T> 00047 static inline void ParamException(const string& error, const string& file, int line) 00048 { 00049 stringstream err; 00050 err << error << " File: " << file << " Line: " << line; 00051 Log.Error() << err.str() << endl; 00052 throw T(err.str()); 00053 } 00054 00055 #define LN_INFO() "Line: " __LINE__ " File: " __FILE__ 00056 #define LN() "Line: " __LINE__ 00057 #define FL() "File: " __FILE__ 00058 00059 #define LOG_ERROR(x) { Log.Error() << x << " [" __FILE__ " (" << __LINE__ << ")]" << endl; } 00060 00062 #define LOG_THROW(X,Y) { ParamException<Y>((X), __FILE__, __LINE__);} 00063 00065 #if defined(_DEBUG) 00066 #define GM_ASSERT(x) { if (!(x)) LOG_THROW("##x", AssertException); } 00067 #else 00068 #define GM_ASSERT(x) {} 00069 #endif 00070 00071 00072 } // !GNUMessenger 00073 00074 #endif

Generated on Tue Oct 5 14:41:47 2004 for GNU Messenger by doxygen 1.3.8