using tree index
[csql.git] / include / Debug.h
blob9e24a7bae8e05be9e5fbe12ad1177136f3841340
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_TreeIndex;
29 extern int DebugDM_SystemDatabase;
30 extern int DebugDM_Database;
31 extern int DebugDM_Table;
32 extern int DebugDM_Predicate;
33 extern int DebugDM_Iterator;
34 extern int DebugDM_Process;
35 extern int DebugDM_Network;
36 extern int DebugDM_Gateway;
37 extern int DebugDM_Adapter;
38 extern int DebugDM_SqlLog;
41 extern int printError1(DbRetVal val, char* fname, int lno, char *format, ...);
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_SystemDatabase,
57 DM_Database,
58 DM_Table,
59 DM_Predicate,
60 DM_Iterator,
61 DM_Process,
62 DM_Network,
63 DM_Gateway,
64 DM_Adapter,
65 DM_SqlLog
67 static char moduleNames[][20] =
69 "Alloc", "VariableAlloc", "Lock", "Trans", "UndoLog", "RedoLog", "Index",
70 "HashIndex", "TreeIndex", "SysDb", "Db", "Table", "Predicate", "Iter",
71 "Procmgmt", "Network", "Gateway", "Adapter", "SqlLog"
74 extern int printDebug1(int module, char *fname, int lineno, char *format, ...);
77 #ifdef DEBUG
78 #define printDebug(a, ...) printDebug1(a, __FILE__, __LINE__, __VA_ARGS__)
79 #else
80 #define printDebug(...) ;
81 #endif
83 //Logging
85 #define MAX_TRACE_LOG_LENGTH 1024
87 enum LogLevel
89 LogOff = 0,
90 LogFine,
91 LogFiner,
92 LogFinest
95 static char levelNames[][10] =
97 "OFF", "FINE", "FINER", "FINEST"
99 #include<Mutex.h>
100 class Logger
102 Mutex mutex_; //guard in case of multi threaded programs
103 int fdLog; //file descriptor
104 LogLevel configLevel; //configuration file setting is cached here.
105 public:
106 int log(LogLevel level, char* filename, int lineNo, char *format, ...);
107 int createLogRecord(LogLevel level, char* filename, int lineNo, char* message, char **in);
108 DbRetVal startLogger(char *filename, bool isCreate = false);
109 void stopLogger();
112 //Global object
113 static Logger logger;
115 #define logFinest(logger, ...) \
117 (logger).log(LogFinest, __FILE__, __LINE__, __VA_ARGS__);\
120 #define logFiner(logger, ...) \
122 (logger).log(LogFiner, __FILE__, __LINE__, __VA_ARGS__);\
125 #define logFine(logger, ...) \
127 (logger).log(LogFine, __FILE__, __LINE__, __VA_ARGS__);\
131 #endif