Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

debug.cpp

Go to the documentation of this file.
00001 #if defined(_DEBUG) || defined(DEBUG)
00002 
00003 #include "debug.hpp"
00004 
00005 
00006 FILE* Log::handle;
00007 int Log::indent_count;
00008 
00009 
00011 
00012 void
00013 Log::Write(const char* str)
00014 {
00015   EnsureOpen();
00016   if (handle) {
00017     std::string s;
00018     for (int i = 0; i < indent_count; ++i) {
00019       s += "  ";
00020     }
00021     s += str;
00022     s += "\n";
00023     fwrite(s.c_str(), 1, s.length(), handle);
00024     fflush(handle);
00025   }
00026 }
00027 
00029 
00030 void
00031 Log::EnsureOpen()
00032 {
00033   if (!handle) {
00034 
00035     #ifdef WIN32
00036       handle = fopen("C:/audiere_debug.log", "w");
00037     #else
00038       std::string home(getenv("HOME"));
00039       handle = fopen((home + "/audiere_debug.log").c_str(), "w");
00040     #endif
00041 
00042     atexit(Close);
00043   }
00044 }
00045 
00047 
00048 void
00049 Log::Close()
00050 {
00051   fclose(handle);
00052 }
00053 
00055 
00056 
00057 #endif

Generated at Mon Jun 10 02:55:12 2002 for audiere by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001