allocator fixes
[csql.git] / include / Debug.h
blob57565c7c6404ff2254a474559243a3b50ad666ed
1 /***************************************************************************
2 * *
3 * Copyright (C) Lakshya Solutions Ltd. All rights reserved. *
4 * *
5 ***************************************************************************/
7 #ifndef DEBUG_H
8 #define DEBUG_H
9 #include<ErrorType.h>
10 //#define DEBUG 1
11 extern int DebugDM_Alloc;
12 extern int DebugDM_VarAlloc;
13 extern int DebugDM_Lock;
14 extern int DebugDM_Transaction;
15 extern int DebugDM_UndoLog;
16 extern int DebugDM_RedoLog;
17 extern int DebugDM_Index;
18 extern int DebugDM_HashIndex;
19 extern int DebugDM_TreeIndex;
20 extern int DebugDM_SystemDatabase;
21 extern int DebugDM_Database;
22 extern int DebugDM_Table;
23 extern int DebugDM_Predicate;
24 extern int DebugDM_Iterator;
25 extern int DebugDM_Process;
26 extern int DebugDM_Network;
27 extern int DebugDM_Gateway;
28 extern int DebugDM_Adapter;
29 extern int DebugDM_SqlLog;
30 extern int DebugDM_CacheServer;
31 extern int DebugDM_TEST;
32 extern int DebugDM_Warning;
34 int printStackTrace();
35 extern int printError1(DbRetVal val, char* fname, int lno, char *format, ...);
37 #define printError(a, ...) printError1(a, __FILE__, __LINE__, __VA_ARGS__)
39 enum DebugModule
41 DM_Alloc = 0,
42 DM_VarAlloc,
43 DM_Lock,
44 DM_Transaction,
45 DM_UndoLog,
46 DM_RedoLog,
47 DM_Index,
48 DM_HashIndex,
49 DM_TreeIndex,
50 DM_SystemDatabase,
51 DM_Database,
52 DM_Table,
53 DM_Predicate,
54 DM_Iterator,
55 DM_Process,
56 DM_Network,
57 DM_Gateway,
58 DM_Adapter,
59 DM_SqlLog,
60 DM_CacheServer,
61 DM_TEST,
62 DM_Warning
64 static char moduleNames[][20] =
66 "Alloc", "VariableAlloc", "Lock", "Trans", "UndoLog", "RedoLog", "Index",
67 "HashIndex", "TreeIndex", "SysDb", "Db", "Table", "Predicate", "Iter",
68 "Procmgmt", "Network", "Gateway", "Adapter", "SqlLog",
69 "CacheServer", "TEST", "Warning"
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 int fdLog; //file descriptor
101 LogLevel configLevel; //configuration file setting is cached here.
102 void rollOverIfRequired();
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 #define logFinest(logger, ...) \
112 (logger).log(LogFinest, __FILE__, __LINE__, __VA_ARGS__);\
115 #define logFiner(logger, ...) \
117 (logger).log(LogFiner, __FILE__, __LINE__, __VA_ARGS__);\
120 #define logFine(logger, ...) \
122 (logger).log(LogFine, __FILE__, __LINE__, __VA_ARGS__);\
126 #endif