Minor fixes
[csql.git] / src / server / Debug.cxx
blob2adde9b27f70eecd81f54a51ca37f80bcce97598
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
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. *
9 * *
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. *
14 * *
15 ***************************************************************************/
16 #include<Debug.h>
18 int DebugDM_Alloc = 0;
19 int DebugDM_VarAlloc = 0;
20 int DebugDM_Lock = 0;
21 int DebugDM_Transaction = 0;
22 int DebugDM_UndoLog = 0;
23 int DebugDM_RedoLog = 0;
24 int DebugDM_HashIndex = 0;
25 int DebugDM_SystemDatabase = 0;
26 int DebugDM_Database = 0;
27 int DebugDM_Table = 0;
28 int DebugDM_TableIterator = 0;
31 int printError1(DbRetVal val, char* fname, int lno, char *format, ...)
33 va_list ap;
34 char mesgBuf[1024];
36 sprintf(mesgBuf, "%d:%lu:%s:%d:",
37 os::getpid(), os::getthrid(), fname, lno);
38 os::write(1, mesgBuf, strlen(mesgBuf));
40 va_start(ap, format);
42 int err = ::vsnprintf(mesgBuf, sizeof(mesgBuf), format,ap);
43 if(err < 0) {
44 return err;
46 os::write(1, mesgBuf, strlen(mesgBuf));
47 strcpy(mesgBuf,"\n");
48 os::write(1, mesgBuf, strlen(mesgBuf));
49 //1->stdout
50 return 0;
55 int printDebug1(int module, char *fname, int lno, char *format, ...)
57 switch(module) {
58 case DM_Alloc: { if (!DebugDM_Alloc) return 1; break; }
59 case DM_VarAlloc: { if (!DebugDM_VarAlloc) return 1; break; }
60 case DM_Lock: { if (!DebugDM_Lock) return 1; break; }
61 case DM_Transaction: { if (!DebugDM_Transaction) return 1; break; }
62 case DM_UndoLog: { if (!DebugDM_UndoLog) return 1; break; }
63 case DM_RedoLog: { if (!DebugDM_RedoLog) return 1; break; }
64 case DM_HashIndex: { if (!DebugDM_HashIndex) return 1; break; }
65 case DM_SystemDatabase: { if (!DebugDM_SystemDatabase) return 1; break; }
66 case DM_Database: { if (!DebugDM_Database) return 1; break; }
67 case DM_Table: { if (!DebugDM_Table) return 1; break; }
68 case DM_Iterator: { if (!DebugDM_TableIterator) return 1; break; }
71 va_list ap;
72 char mesgBuf[1024];
74 sprintf(mesgBuf, "D:%s:%d:%lu:%s:%d:", moduleNames[module],
75 os::getpid(), os::getthrid(), fname, lno);
76 os::write(1, mesgBuf, strlen(mesgBuf));
78 va_start(ap, format);
80 int err = ::vsnprintf(mesgBuf, sizeof(mesgBuf), format,ap);
81 if(err < 0) {
82 return err;
84 os::write(1, mesgBuf, strlen(mesgBuf));
85 strcpy(mesgBuf,"\n");
86 os::write(1, mesgBuf, strlen(mesgBuf));
87 //1->stdout
88 return 0;