Trie Index changes for retreiving metadata through catalog tool and
[csql.git] / include / Debug.h
blob01f29202a640ead62e50e185bcc99ffade64f6e7
1 /***************************************************************************
2 * *
3 * Copyright (C) Lakshya Solutions Ltd. All rights reserved. *
4 * *
5 ***************************************************************************/
7 #ifndef DEBUG_H
8 #define DEBUG_H
9 #include<os.h>
10 #include<ErrorType.h>
11 #include<FaultTest.h>
12 #define DEBUG 1
13 extern int DebugDM_Alloc;
14 extern int DebugDM_VarAlloc;
15 extern int DebugDM_Mutex;
16 extern int DebugDM_Lock;
17 extern int DebugDM_Transaction;
18 extern int DebugDM_UndoLog;
19 extern int DebugDM_RedoLog;
20 extern int DebugDM_Recovery;
21 extern int DebugDM_Index;
22 extern int DebugDM_HashIndex;
23 extern int DebugDM_TreeIndex;
24 extern int DebugDM_TrieIndex;
25 extern int DebugDM_SystemDatabase;
26 extern int DebugDM_Database;
27 extern int DebugDM_Table;
28 extern int DebugDM_Predicate;
29 extern int DebugDM_Iterator;
30 extern int DebugDM_Process;
31 extern int DebugDM_Network;
32 extern int DebugDM_Gateway;
33 extern int DebugDM_Adapter;
34 extern int DebugDM_SqlLog;
35 extern int DebugDM_CacheServer;
36 extern int DebugDM_TEST;
37 extern int DebugDM_Warning;
39 int printStackTrace();
40 #ifdef WINNT
41 DllExport int printError1(DbRetVal val, char* fname, int lno, char *format, ...);
42 #else
43 extern int printError1(DbRetVal val, char* fname, int lno, char *format, ...);
44 #endif
45 #define printError(a, ...) printError1(a, __FILE__, __LINE__, __VA_ARGS__)
47 enum DebugModule
49 DM_Alloc = 0,
50 DM_VarAlloc,
51 DM_Mutex,
52 DM_Lock,
53 DM_Transaction,
54 DM_UndoLog,
55 DM_RedoLog,
56 DM_Recovery,
57 DM_Index,
58 DM_HashIndex,
59 DM_TreeIndex,
60 DM_TrieIndex,
61 DM_SystemDatabase,
62 DM_Database,
63 DM_Table,
64 DM_Predicate,
65 DM_Iterator,
66 DM_Process,
67 DM_Network,
68 DM_Gateway,
69 DM_Adapter,
70 DM_SqlLog,
71 DM_CacheServer,
72 DM_TEST,
73 DM_Warning
75 static char moduleNames[][20] =
77 "Alloc", "VariableAlloc", "Mutex", "Lock", "Trans", "UndoLog", "RedoLog", "Recovery", "Index",
78 "HashIndex", "TreeIndex", "TrieIndex", "SysDb", "Db", "Table", "Predicate", "Iter",
79 "Procmgmt", "Network", "Gateway", "Adapter", "SqlLog",
80 "CacheServer", "TEST", "Warning"
82 #ifdef WINNT
83 DllExport int printDebug1(int module, char* fname, int lno, char *format, ...);
84 #else
85 extern int printDebug1(int module, char *fname, int lineno, char *format, ...);
86 #endif
88 #ifdef DEBUG
89 #define printDebug(a, ...) printDebug1(a, __FILE__, __LINE__, __VA_ARGS__)
90 #else
91 #define printDebug(...) ;
92 #endif
94 //Logging
96 #define MAX_TRACE_LOG_LENGTH 1024
98 enum LogLevel
100 LogOff = 0,
101 LogFine,
102 LogFiner,
103 LogFinest
106 static char levelNames[][10] =
108 "OFF", "FINE", "FINER", "FINEST"
110 #include<Mutex.h>
111 class DllExport Logger
113 int fdLog; //file descriptor
114 LogLevel configLevel; //configuration file setting is cached here.
115 void rollOverIfRequired();
116 public:
117 int log(LogLevel level, char* filename, int lineNo, char *format, ...);
118 int createLogRecord(LogLevel level, char* filename, int lineNo, char* message, char **in);
119 DbRetVal startLogger(char *filename, bool isCreate = false);
120 void stopLogger();
123 #define logFinest(logger, ...) \
125 (logger).log(LogFinest, __FILE__, __LINE__, __VA_ARGS__);\
128 #define logFiner(logger, ...) \
130 (logger).log(LogFiner, __FILE__, __LINE__, __VA_ARGS__);\
133 #define logFine(logger, ...) \
135 (logger).log(LogFine, __FILE__, __LINE__, __VA_ARGS__);\
139 #endif