removing unsupported option m in cachetable
[csql.git] / include / Debug.h
blob26a450e29e1992fb3e30c0ea12de488c7491f986
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;
36 extern int printError1(DbRetVal val, char* fname, int lno, char *format, ...);
38 #define printError(a, ...) printError1(a, __FILE__, __LINE__, __VA_ARGS__)
40 enum DebugModule
42 DM_Alloc = 0,
43 DM_VarAlloc,
44 DM_Lock,
45 DM_Transaction,
46 DM_UndoLog,
47 DM_RedoLog,
48 DM_Index,
49 DM_HashIndex,
50 DM_SystemDatabase,
51 DM_Database,
52 DM_Table,
53 DM_Predicate,
54 DM_Iterator,
55 DM_Process
57 static char moduleNames[][20] =
59 "Alloc", "VariableAlloc", "Lock", "Trans", "UndoLog", "RedoLog", "Index",
60 "HashIndex", "SysDb", "Db", "Table", "Predicate", "Iter", "Procmgmt"
63 extern int printDebug1(int module, char *fname, int lineno, char *format, ...);
66 #ifdef DEBUG
67 #define printDebug(a, ...) printDebug1(a, __FILE__, __LINE__, __VA_ARGS__)
68 #else
69 #define printDebug(...) ;
70 #endif
72 //Logging
74 #define MAX_TRACE_LOG_LENGTH 1024
76 enum LogLevel
78 LogOff = 0,
79 LogFine,
80 LogFiner,
81 LogFinest
84 static char levelNames[][10] =
86 "OFF", "FINE", "FINER", "FINEST"
88 #include<Mutex.h>
89 class Logger
91 Mutex mutex_; //guard in case of multi threaded programs
92 int fdLog; //file descriptor
93 LogLevel configLevel; //configuration file setting is cached here.
94 public:
95 int log(LogLevel level, char* filename, int lineNo, char *format, ...);
96 int createLogRecord(LogLevel level, char* filename, int lineNo, char* message, char **in);
97 DbRetVal startLogger(char *filename, bool isCreate = false);
98 void stopLogger();
101 //Global object
102 static Logger logger;
104 #define logFinest(logger, ...) \
106 (logger).log(LogFinest, __FILE__, __LINE__, __VA_ARGS__);\
109 #define logFiner(logger, ...) \
111 (logger).log(LogFiner, __FILE__, __LINE__, __VA_ARGS__);\
114 #define logFine(logger, ...) \
116 (logger).log(LogFine, __FILE__, __LINE__, __VA_ARGS__);\
120 #endif