Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
debug.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file debug.cpp
1 /* This software is distributed under the GNU Lesser General Public License */
2 //==========================================================================
3 //
4 // debug.cpp
5 //
6 //==========================================================================
7 // $Id: debug.cpp,v 1.10 2001/11/07 13:58:09 pick Exp $
8 
9 #include <GTL/debug.h>
10 
11 #include <fstream>
12 #include <cstdarg>
13 #include <cstdio>
14 
15 #ifdef __GTL_MSVCC
16 # ifdef _DEBUG
17 # ifndef SEARCH_MEMORY_LEAKS_ENABLED
18 # error SEARCH NOT ENABLED
19 # endif
20 # define new DEBUG_NEW
21 # undef THIS_FILE
22  static char THIS_FILE[] = __FILE__;
23 # endif // _DEBUG
24 #endif // __GTL_MSVCC
25 
27 
28 ostream* GTL_debug::GTLerr = 0;
29 
30 void GTL_debug::debug_message (const char* message, ...)
31 {
32 #ifdef _DEBUG
33  va_list arg_list;
34  va_start(arg_list, message);
35 
36  char buf[1024];
37  vsprintf(buf, message, arg_list);
38  if (GTLerr) {
39  os() << buf;
40  }
41 #endif
42 }
43 
45 {
46  if (!GTLerr) {
47 #ifdef __GTL_MSVCC
48  GTLerr = new ofstream ("ERRLOG.txt", ios::out | ios::app);
49 #else
50  GTLerr = &cerr;
51 #endif
52  }
53 }
54 
56 {
57  if (GTLerr) {
58 #ifdef __GTL_MSVCC
59  ((ofstream*) GTLerr)->close();
60  delete GTLerr;
61  GTLerr = 0;
62 #endif
63  }
64 }
65 
67 
68 //--------------------------------------------------------------------------
69 // end of file
70 //--------------------------------------------------------------------------