File indexing completed on 2025-08-03 08:19:38
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <GTL/debug.h>
0010
0011 #include <fstream>
0012 #include <cstdarg>
0013 #include <cstdio>
0014
0015 #ifdef __GTL_MSVCC
0016 # ifdef _DEBUG
0017 # ifndef SEARCH_MEMORY_LEAKS_ENABLED
0018 # error SEARCH NOT ENABLED
0019 # endif
0020 # define new DEBUG_NEW
0021 # undef THIS_FILE
0022 static char THIS_FILE[] = __FILE__;
0023 # endif
0024 #endif
0025
0026 __GTL_BEGIN_NAMESPACE
0027
0028 ostream* GTL_debug::GTLerr = 0;
0029
0030 void GTL_debug::debug_message (const char* message, ...)
0031 {
0032 #ifdef _DEBUG
0033 va_list arg_list;
0034 va_start(arg_list, message);
0035
0036 char buf[1024];
0037 vsprintf(buf, message, arg_list);
0038 if (GTLerr) {
0039 os() << buf;
0040 }
0041 #endif
0042 }
0043
0044 void GTL_debug::init_debug ()
0045 {
0046 if (!GTLerr) {
0047 #ifdef __GTL_MSVCC
0048 GTLerr = new ofstream ("ERRLOG.txt", ios::out | ios::app);
0049 #else
0050 GTLerr = &cerr;
0051 #endif
0052 }
0053 }
0054
0055 void GTL_debug::close_debug ()
0056 {
0057 if (GTLerr) {
0058 #ifdef __GTL_MSVCC
0059 ((ofstream*) GTLerr)->close();
0060 delete GTLerr;
0061 GTLerr = 0;
0062 #endif
0063 }
0064 }
0065
0066 __GTL_END_NAMESPACE
0067
0068
0069
0070