1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 ***************************************************************************/
19 int DebugDM_Alloc
= 0;
20 int DebugDM_VarAlloc
= 0;
22 int DebugDM_Transaction
= 0;
23 int DebugDM_UndoLog
= 0;
24 int DebugDM_RedoLog
= 0;
25 int DebugDM_Index
= 0;
26 int DebugDM_HashIndex
= 0;
27 int DebugDM_TreeIndex
= 0;
28 int DebugDM_SystemDatabase
= 0;
29 int DebugDM_Database
= 0;
30 int DebugDM_Table
= 0;
31 int DebugDM_Predicate
= 0;
32 int DebugDM_TableIterator
= 0;
33 int DebugDM_Process
=0;
34 int DebugDM_Network
=0;
35 int DebugDM_Gateway
=0;
36 int DebugDM_Adapter
=0;
38 int DebugDM_CacheServer
=0;
40 int DebugDM_Warning
=0;
45 size_t size
= backtrace(array
, 10);
46 backtrace_symbols_fd(array
, size
, 2);
51 int printError1(DbRetVal val
, char* fname
, int lno
, char *format
, ...)
56 struct timeval timeStamp
;
57 os::gettimeofday(&timeStamp
);
58 struct tm
*tempTm
= os::localtime(&timeStamp
.tv_sec
);
60 #if defined(SOLARIS) && defined(REMOTE_SOLARIS)
61 strftime(tempBuffer
, 25, "%d/%m/%Y %H:%M:%S", (struct std::tm
*) tempTm
);
63 strftime(tempBuffer
, 25, "%d/%m/%Y %H:%M:%S", tempTm
);
66 if (strncasecmp(Conf::config
.getStderrFile(),"stderr", 6) == 0) fd
= 2;
68 fd
= os::openFileForAppend(Conf::config
.getStderrFile(), O_CREAT
);
72 snprintf(mesgBuf
, MAX_TRACE_LOG_LENGTH
, "%s.%6d:%5d:%10lu:%s:%d:",
73 tempBuffer
, timeStamp
.tv_usec
, os::getpid(), os::getthrid(), fname
, lno
);
75 os::write(fd
, mesgBuf
, strlen(mesgBuf
));
79 int err
= ::vsnprintf(mesgBuf
, sizeof(mesgBuf
), format
,ap
);
80 if (err
< 0) { return err
; }
82 os::write(fd
, mesgBuf
, strlen(mesgBuf
));
84 os::write(fd
, mesgBuf
, strlen(mesgBuf
));
89 int printDebug1(int module
, char *fname
, int lno
, char *format
, ...)
92 case DM_Alloc
: { if (!DebugDM_Alloc
) return 1; break; }
93 case DM_VarAlloc
: { if (!DebugDM_VarAlloc
) return 1; break; }
94 case DM_Lock
: { if (!DebugDM_Lock
) return 1; break; }
95 case DM_Transaction
: { if (!DebugDM_Transaction
) return 1; break; }
96 case DM_UndoLog
: { if (!DebugDM_UndoLog
) return 1; break; }
97 case DM_RedoLog
: { if (!DebugDM_RedoLog
) return 1; break; }
98 case DM_HashIndex
: { if (!DebugDM_HashIndex
) return 1; break; }
99 case DM_TreeIndex
: { if (!DebugDM_TreeIndex
) return 1; break; }
100 case DM_SystemDatabase
: { if (!DebugDM_SystemDatabase
) return 1; break; }
101 case DM_Database
: { if (!DebugDM_Database
) return 1; break; }
102 case DM_Table
: { if (!DebugDM_Table
) return 1; break; }
103 case DM_Iterator
: { if (!DebugDM_TableIterator
) return 1; break; }
104 case DM_Predicate
: { if (!DebugDM_Predicate
) return 1; break; }
105 case DM_Process
: { if (!DebugDM_Process
) return 1; break; }
106 case DM_Network
: { if (!DebugDM_Network
) return 1; break; }
107 case DM_Gateway
: { if (!DebugDM_Gateway
) return 1; break; }
108 case DM_Adapter
: { if (!DebugDM_Adapter
) return 1; break; }
109 case DM_SqlLog
: { if (!DebugDM_SqlLog
) return 1; break; }
110 case DM_CacheServer
: { if (!DebugDM_CacheServer
) return 1; break; }
111 case DM_TEST
: { if (!DebugDM_TEST
) return 1; break; }
112 case DM_Warning
: { if (!DebugDM_Warning
) return 1; break; }
119 sprintf(mesgBuf
, "D:%s:%d:%lu:%s:%d:", moduleNames
[module
],
120 os::getpid(), os::getthrid(), fname
, lno
);
121 os::write(1, mesgBuf
, strlen(mesgBuf
));
123 va_start(ap
, format
);
125 int err
= ::vsnprintf(mesgBuf
, sizeof(mesgBuf
), format
,ap
);
129 os::write(1, mesgBuf
, strlen(mesgBuf
));
130 strcpy(mesgBuf
,"\n");
131 os::write(1, mesgBuf
, strlen(mesgBuf
));