debug.h

00001 /* -- 2007-05-07 -- 
00002  *  ardev - an augmented reality library for robot developers
00003  *  Copyright 2005-2007 - Toby Collett (ardev _at_ plan9.net.nz)
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Lesser General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2.1 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00013  *  Lesser General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU Lesser General Public
00016  *  License along with this library; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
00018  *
00019  */
00020 #ifndef _ARDEV_DEBUG_H
00021 #define _ARDEV_DEBUG_H
00022 
00023 #include <ardev/ardev.h>
00024 #include <stdarg.h>
00025 #include <assert.h>
00026 // helper functions/macros for debug output
00027 
00028 const int ARDBG_THREAD = 6;
00029 const int ARDBG_VERBOSE = 5;
00030 const int ARDBG_INFO = 3;
00031 const int ARDBG_WARN = 2;
00032 const int ARDBG_ERR = 1;
00033 
00034 
00035 
00036 #ifdef DEBUG
00037 inline void dbg_print(int Level, const char* format, ...)
00038 {
00039         va_list ap;
00040         va_start(ap,format);
00041 
00042         if (Level <= ARDev::DebugLevel)
00043         {
00044                 fprintf(stderr,"%X: ",(int) pthread_self());
00045                 vfprintf(stderr,format, ap);
00046                 fflush(stderr);
00047         }
00048         va_end(ap);
00049 
00050 };
00051 #else
00052 inline void dbg_print(int Level, const char* format, ...)
00053 {
00054 };
00055 #endif
00056 
00057 
00058 #endif

SourceForge.net Logo Generated on Sat May 12 15:25:43 2007 for ardev by doxygen 1.5.1