00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 }
00073
00074
#endif