$search
00001 /**************************************************************************** 00002 * 00003 * Copyright (c) 2006 Carrick Detweiler 00004 * and Massachusetts Institute of Technology 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 * 00020 * $Id: debug.h 142 2007-01-05 17:10:44Z carrick $ 00021 ****************************************************************************/ 00022 00023 00024 #if !defined( DEBUG_H ) 00025 #define DEBUG_H 00026 #include "stdio.h" 00027 //#include "console.h" 00028 00032 #ifndef DEBUG 00033 #define DEBUG 4 00034 #endif 00035 00039 //#define DEBUG_PRINTF printf 00040 #define DEBUG_PRINTF(...) 00041 00046 //#define DEBUG_PRETTY_PRINT 00047 00051 #ifndef DEBUG_PRETTY_PRINT 00052 #define DEBUG_PRINTLINE(pre,...) \ 00053 { \ 00054 DEBUG_PRINTF(pre ); \ 00055 DEBUG_PRINTF("%s:%d %s() ", \ 00056 __FILE__,__LINE__,__FUNCTION__); \ 00057 DEBUG_PRINTF( __VA_ARGS__ ); \ 00058 } 00059 #else /* DEBUG_PRETTY_PRINT */ 00060 00061 #define DEBUG_PRINTLINE(pre,...) \ 00062 { char __debugTmp[45]; \ 00063 DEBUG_PRINTF(pre ); \ 00064 snprintf(__debugTmp,45,"%-18s %-4d %s()", \ 00065 __FILE__,__LINE__,__FUNCTION__); \ 00066 DEBUG_PRINTF("%-45s | ",__debugTmp); \ 00067 DEBUG_PRINTF( __VA_ARGS__ ); \ 00068 DEBUG_PRINTG("\n"); 00069 } 00070 #endif 00071 00075 #define PRINTF(...) 00076 //#define PRINTF(...) 00077 00078 00082 #define TBD(...) \ 00083 DEBUG_PRINTLINE("TBD: ",__VA_ARGS__); 00084 00085 00086 #if DEBUG > 0 00087 00091 #define DEBUG1(...) \ 00092 DEBUG_PRINTLINE("DEBUG1: ",__VA_ARGS__); 00093 00094 #if DEBUG > 1 00095 00099 #define DEBUG2(...) \ 00100 DEBUG_PRINTLINE("DEBUG2: ",__VA_ARGS__); 00101 00102 #if DEBUG > 2 00103 00107 #define DEBUG3(...) \ 00108 DEBUG_PRINTLINE("DEBUG3: ",__VA_ARGS__); 00109 00110 #if DEBUG > 3 00111 00115 #define DEBUG4(...) \ 00116 DEBUG_PRINTLINE("DEBUG4: ",__VA_ARGS__); 00117 00118 #else 00119 #define DEBUG4(...) 00120 #endif /* DEBUG > 3 */ 00121 #else 00122 #define DEBUG4(...) 00123 #define DEBUG3(...) 00124 #endif /* DEBUG > 2 */ 00125 #else 00126 #define DEBUG4(...) 00127 #define DEBUG3(...) 00128 #define DEBUG2(...) 00129 #endif /* DEBUG > 1 */ 00130 #else 00131 #define DEBUG4(...) 00132 #define DEBUG3(...) 00133 #define DEBUG2(...) 00134 #define DEBUG1(...) 00135 #endif /* DEBUG > 0 */ 00136 00137 00138 #endif /* DEBUG_H */