Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

debug.cpp

Go to the documentation of this file.
00001 // debug.cpp
00002 //
00003 // Copyright (C) 2001, Chris Laurel <claurel@shatters.net>
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 
00010 #ifdef _MSC_VER
00011 #include <windows.h>
00012 #endif
00013 #include <stdio.h>
00014 #include <cstdarg>
00015 
00016 #ifndef _WIN32
00017 #ifndef MACOSX_PB
00018 #include <config.h>
00019 #endif /* MACOSX_PB */
00020 #endif /* _WIN32 */
00021 
00022 static int debugVerbosity = 0;
00023 
00024 #if defined(DEBUG) || defined(_DEBUG)
00025 void DebugPrint(int level, char *format, ...)
00026 {
00027     va_list args;
00028     va_start(args, format);
00029 
00030     if (level <= debugVerbosity)
00031     {
00032 #ifdef _MSC_VER
00033         if (IsDebuggerPresent())
00034         {
00035             char buf[1024];
00036             vsprintf(buf, format, args);
00037             OutputDebugString(buf);
00038         }
00039         else
00040         {
00041             vfprintf(stdout, format, args);
00042         }
00043 #else
00044         vfprintf(stderr, format, args);
00045 #endif
00046     }
00047 
00048     va_end(args);
00049 }
00050 #endif /* DEBUG */
00051 
00052 
00053 void SetDebugVerbosity(int dv)
00054 {
00055     if(dv<0)
00056         dv=0;
00057     debugVerbosity = dv;
00058 }
00059 
00060 
00061 int GetDebugVerbosity()
00062 {
00063     return debugVerbosity;
00064 }

Generated on Sat Jan 14 22:30:32 2006 for Celestia by  doxygen 1.4.1