Adding tests for composite keys
[csql.git] / include / Debug.h
blob0592231aaa3d89f65f4a9241b65d33f17d78b775
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 #ifndef DEBUG_H
17 #define DEBUG_H
18 #include<ErrorType.h>
19 #define DEBUG 1
20 extern int DebugDM_Alloc;
21 extern int DebugDM_VarAlloc;
22 extern int DebugDM_Lock;
23 extern int DebugDM_Transaction;
24 extern int DebugDM_UndoLog;
25 extern int DebugDM_RedoLog;
26 extern int DebugDM_Index;
27 extern int DebugDM_HashIndex;
28 extern int DebugDM_SystemDatabase;
29 extern int DebugDM_Database;
30 extern int DebugDM_Table;
31 extern int DebugDM_Predicate;
32 extern int DebugDM_Iterator;
33 extern int DebugDM_Process;
34 extern int DebugDM_Network;
35 extern int DebugDM_Gateway;
36 extern int DebugDM_Adapter;
37 extern int DebugDM_SqlLog;
40 extern int printError1(DbRetVal val, char* fname, int lno, char *format, ...);
42 #define printError(a, ...) printError1(a, __FILE__, __LINE__, __VA_ARGS__)
44 enum DebugModule
46 DM_Alloc = 0,
47 DM_VarAlloc,
48 DM_Lock,
49 DM_Transaction,
50 DM_UndoLog,
51 DM_RedoLog,
52 DM_Index,
53 DM_HashIndex,
54 DM_SystemDatabase,
55 DM_Database,
56 DM_Table,
57 DM_Predicate,
58 DM_Iterator,
59 DM_Process,
60 DM_Network,
61 DM_Gateway,
62 DM_Adapter,
63 DM_SqlLog
65 static char moduleNames[][20] =
67 "Alloc", "VariableAlloc", "Lock", "Trans", "UndoLog", "RedoLog", "Index",
68 "HashIndex", "SysDb", "Db", "Table", "Predicate", "Iter", "Procmgmt",
69 "Network", "Gateway", "Adapter", "SqlLog"
72 extern int printDebug1(int module, char *fname, int lineno, char *format, ...);
75 #ifdef DEBUG
76 #define printDebug(a, ...) printDebug1(a, __FILE__, __LINE__, __VA_ARGS__)
77 #else
78 #define printDebug(...) ;
79 #endif
81 //Logging
83 #define MAX_TRACE_LOG_LENGTH 1024
85 enum LogLevel
87 LogOff = 0,
88 LogFine,
89 LogFiner,
90 LogFinest
93 static char levelNames[][10] =
95 "OFF", "FINE", "FINER", "FINEST"
97 #include<Mutex.h>
98 class Logger
100 Mutex mutex_; //guard in case of multi threaded programs
101 int fdLog; //file descriptor
102 LogLevel configLevel; //configuration file setting is cached here.
103 public:
104 int log(LogLevel level, char* filename, int lineNo, char *format, ...);
105 int createLogRecord(LogLevel level, char* filename, int lineNo, char* message, char **in);
106 DbRetVal startLogger(char *filename, bool isCreate = false);
107 void stopLogger();
110 //Global object
111 static Logger logger;
113 #define logFinest(logger, ...) \
115 (logger).log(LogFinest, __FILE__, __LINE__, __VA_ARGS__);\
118 #define logFiner(logger, ...) \
120 (logger).log(LogFiner, __FILE__, __LINE__, __VA_ARGS__);\
123 #define logFine(logger, ...) \
125 (logger).log(LogFine, __FILE__, __LINE__, __VA_ARGS__);\
129 #endif