src/server/Debug.cxx

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2007 by www.databasecache.com                           *
00003  *   Contact: praba_tuty@databasecache.com                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015   ***************************************************************************/
00016 #include<Debug.h>
00017 
00018 int DebugDM_Alloc = 0;
00019 int DebugDM_VarAlloc = 0;
00020 int DebugDM_Lock = 0;
00021 int DebugDM_Transaction = 0;
00022 int DebugDM_UndoLog = 0;
00023 int DebugDM_RedoLog = 0;
00024 int DebugDM_Index = 0;
00025 int DebugDM_HashIndex = 0;
00026 int DebugDM_SystemDatabase = 0;
00027 int DebugDM_Database = 0;
00028 int DebugDM_Table = 0;
00029 int DebugDM_Predicate = 0;
00030 int DebugDM_TableIterator = 0;
00031 int DebugDM_Process=0;
00032 int DebugDM_Network=0;
00033 int DebugDM_Gateway=0;
00034 int DebugDM_Adapter=0;
00035 int DebugDM_SqlLog=0;
00036 
00037 int printError1(DbRetVal val, char* fname, int lno, char *format, ...)
00038 {
00039   va_list ap;
00040   char mesgBuf[1024];
00041 
00042   sprintf(mesgBuf, "%d:%lu:%s:%d:",
00043            os::getpid(), os::getthrid(), fname, lno);
00044   os::write(2, mesgBuf, strlen(mesgBuf));
00045 
00046   va_start(ap, format);
00047 
00048   int err = ::vsnprintf(mesgBuf, sizeof(mesgBuf), format,ap);
00049   if(err < 0) {
00050       return err;
00051   }
00052   os::write(2, mesgBuf, strlen(mesgBuf));
00053   strcpy(mesgBuf,"\n");
00054   os::write(2, mesgBuf, strlen(mesgBuf));
00055    //2->stderr
00056   return 0;
00057 }
00058 
00059 
00060 
00061 int printDebug1(int module, char *fname, int lno, char *format, ...)
00062 {
00063   switch(module) {
00064      case DM_Alloc: { if (!DebugDM_Alloc) return 1; break; }
00065      case DM_VarAlloc: { if (!DebugDM_VarAlloc) return 1; break; }
00066      case DM_Lock: { if (!DebugDM_Lock) return 1; break; }
00067      case DM_Transaction: { if (!DebugDM_Transaction) return 1; break; }
00068      case DM_UndoLog: { if (!DebugDM_UndoLog) return 1; break; }
00069      case DM_RedoLog: { if (!DebugDM_RedoLog) return 1; break; }
00070      case DM_HashIndex: { if (!DebugDM_HashIndex) return 1; break; }
00071      case DM_SystemDatabase: { if (!DebugDM_SystemDatabase) return 1; break; }
00072      case DM_Database: { if (!DebugDM_Database) return 1; break; }
00073      case DM_Table: { if (!DebugDM_Table) return 1; break; }
00074      case DM_Iterator: { if (!DebugDM_TableIterator) return 1; break; }
00075      case DM_Predicate: { if (!DebugDM_Predicate) return 1; break; }
00076      case DM_Process: { if (!DebugDM_Process) return 1; break; }
00077      case DM_Network: { if (!DebugDM_Network) return 1; break; }
00078      case DM_Gateway: { if (!DebugDM_Gateway) return 1; break; }
00079      case DM_Adapter: { if (!DebugDM_Adapter) return 1; break; }
00080      case DM_SqlLog: { if (!DebugDM_SqlLog) return 1; break; }
00081 
00082   }
00083 
00084   va_list ap;
00085   char mesgBuf[1024];
00086 
00087   sprintf(mesgBuf, "D:%s:%d:%lu:%s:%d:", moduleNames[module],
00088            os::getpid(), os::getthrid(), fname, lno);
00089   os::write(1, mesgBuf, strlen(mesgBuf));
00090 
00091   va_start(ap, format);
00092 
00093   int err = ::vsnprintf(mesgBuf, sizeof(mesgBuf), format,ap);
00094   if(err < 0) {
00095       return err;
00096   }
00097   os::write(1, mesgBuf, strlen(mesgBuf));
00098   strcpy(mesgBuf,"\n");
00099   os::write(1, mesgBuf, strlen(mesgBuf));
00100    //1->stdout
00101   return 0;
00102 }

Generated on Mon Jun 9 22:37:15 2008 for csql by  doxygen 1.4.7