Trie Implementation
[csql.git] / include / Debug.h
blob0797d2bfeb8dbdefb6657270b5d32f81c2bd3116
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_Lock;
16 extern int DebugDM_Transaction;
17 extern int DebugDM_UndoLog;
18 extern int DebugDM_RedoLog;
19 extern int DebugDM_Index;
20 extern int DebugDM_HashIndex;
21 extern int DebugDM_TreeIndex;
22 extern int DebugDM_TrieIndex;
23 extern int DebugDM_SystemDatabase;
24 extern int DebugDM_Database;
25 extern int DebugDM_Table;
26 extern int DebugDM_Predicate;
27 extern int DebugDM_Iterator;
28 extern int DebugDM_Process;
29 extern int DebugDM_Network;
30 extern int DebugDM_Gateway;
31 extern int DebugDM_Adapter;
32 extern int DebugDM_SqlLog;
33 extern int DebugDM_CacheServer;
34 extern int DebugDM_TEST;
35 extern int DebugDM_Warning;
37 int printStackTrace();
38 #ifdef WINNT
39 DllExport int printError1(DbRetVal val, char* fname, int lno, const char *format, ...);
40 #else
41 extern int printError1(DbRetVal val, char* fname, int lno, const char *format, ...);
42 #endif
43 #define printError(a, ...) printError1(a, __FILE__, __LINE__, __VA_ARGS__)
45 enum DebugModule
47 DM_Alloc = 0,
48 DM_VarAlloc,
49 DM_Lock,
50 DM_Transaction,
51 DM_UndoLog,
52 DM_RedoLog,
53 DM_Index,
54 DM_HashIndex,
55 DM_TreeIndex,
56 DM_TrieIndex,
57 DM_SystemDatabase,
58 DM_Database,
59 DM_Table,
60 DM_Predicate,
61 DM_Iterator,
62 DM_Process,
63 DM_Network,
64 DM_Gateway,
65 DM_Adapter,
66 DM_SqlLog,
67 DM_CacheServer,
68 DM_TEST,
69 DM_Warning
71 static char moduleNames[][20] =
73 "Alloc", "VariableAlloc", "Lock", "Trans", "UndoLog", "RedoLog", "Index",
74 "HashIndex", "TreeIndex", "TrieIndex", "SysDb", "Db", "Table", "Predicate", "Iter",
75 "Procmgmt", "Network", "Gateway", "Adapter", "SqlLog",
76 "CacheServer", "TEST", "Warning"
79 extern int printDebug1(int module, char *fname, int lineno, const char *format, ...);
82 #ifdef DEBUG
83 #define printDebug(a, ...) printDebug1(a, __FILE__, __LINE__, __VA_ARGS__)
84 #else
85 #define printDebug(...) ;
86 #endif
88 //Logging
90 #define MAX_TRACE_LOG_LENGTH 1024
92 enum LogLevel
94 LogOff = 0,
95 LogFine,
96 LogFiner,
97 LogFinest
100 static char levelNames[][10] =
102 "OFF", "FINE", "FINER", "FINEST"
104 #include<Mutex.h>
105 class DllExport Logger
107 int fdLog; //file descriptor
108 LogLevel configLevel; //configuration file setting is cached here.
109 void rollOverIfRequired();
110 public:
111 int log(LogLevel level, char* filename, int lineNo, char *format, ...);
112 int createLogRecord(LogLevel level, char* filename, int lineNo, char* message, char **in);
113 DbRetVal startLogger(char *filename, bool isCreate = false);
114 void stopLogger();
117 #define logFinest(logger, ...) \
119 (logger).log(LogFinest, __FILE__, __LINE__, __VA_ARGS__);\
122 #define logFiner(logger, ...) \
124 (logger).log(LogFiner, __FILE__, __LINE__, __VA_ARGS__);\
127 #define logFine(logger, ...) \
129 (logger).log(LogFine, __FILE__, __LINE__, __VA_ARGS__);\
133 #endif