EHS Embedded HTTP Server
1.5.0.132
|
00001 /* $Id: debug.h 81 2012-03-20 12:03:05Z felfert $ 00002 * 00003 * EHS is a library for embedding HTTP(S) support into a C++ application 00004 * 00005 * Copyright (C) 2004 Zachary J. Hansen 00006 * 00007 * Code cleanup, new features and bugfixes: Copyright (C) 2010 Fritz Elfert 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License version 2.1 as published by the Free Software Foundation; 00012 * 00013 * This library 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 GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 * This can be found in the 'COPYING' file. 00023 * 00024 */ 00025 00026 #ifndef _DEBUG_H 00027 #define _DEBUG_H 00028 00029 #ifdef HAVE_CONFIG_H 00030 # include "config.h" 00031 #endif 00032 00033 #ifdef EHS_DEBUG 00034 # include <iostream> 00035 # include <cstdio> 00036 # include <cstdarg> 00037 #endif 00038 00039 static inline void _ehs_trace(const char* 00040 #ifdef EHS_DEBUG 00041 szFormat 00042 #endif 00043 ... ) 00044 { 00045 #ifdef EHS_DEBUG 00046 const int bufsize = 100000; 00047 char buf [ bufsize ] ; 00048 va_list VarList; 00049 va_start( VarList, szFormat ); 00050 vsnprintf(buf, bufsize - 1, szFormat, VarList ) ; 00051 va_end ( VarList ) ; 00052 # ifdef _WIN32 00053 OutputDebugStringA(buf) ; 00054 # else 00055 std::cerr << buf << std::endl; std::cerr.flush(); 00056 # endif 00057 #endif 00058 } 00059 00060 #define _STR(x) #x 00061 #define EHS_TODO (_message) message (" *** TODO: " ##_message "\t\t\t\t" __FILE__ ":" _STR(__LINE__) ) 00062 #define EHS_FUTURE (_message) message (" *** FUTURE: " ##_message "\t\t\t\t" __FILE__ ":" _STR(__LINE__) ) 00063 #define EHS_TODOCUMENT (_message) message (" *** TODOCUMENT: " ##_message "\t\t\t\t" __FILE__ ":" _STR(__LINE__) ) 00064 #define EHS_DEBUGCODE (_message) message (" *** DEBUG CODE (REMOVE!): " ##_message "\t\t\t\t" __FILE__ ":" _STR(__LINE__) ) 00065 00066 #ifdef HAVE_GNU_VAMACROS 00067 # ifdef HAVE_GNU_PRETTY_FUNCTION 00068 # define EHS_TRACE(fmt, ...) _ehs_trace("%s [%s:%d]: " fmt, __PRETTY_FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__) 00069 # else 00070 # define EHS_TRACE(fmt, ...) _ehs_trace("%s [%s:%d]: " fmt, __func__, __FILE__, __LINE__, ##__VA_ARGS__) 00071 # endif 00072 #else 00073 # define EHS_TRACE _ehs_trace 00074 #endif 00075 00076 #endif // _DEBUG_H