00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef DEBUG_H
00017 #define DEBUG_H
00018 #include<ErrorType.h>
00019 #define DEBUG 1
00020 extern int DebugDM_Alloc;
00021 extern int DebugDM_VarAlloc;
00022 extern int DebugDM_Lock;
00023 extern int DebugDM_Transaction;
00024 extern int DebugDM_UndoLog;
00025 extern int DebugDM_RedoLog;
00026 extern int DebugDM_Index;
00027 extern int DebugDM_HashIndex;
00028 extern int DebugDM_SystemDatabase;
00029 extern int DebugDM_Database;
00030 extern int DebugDM_Table;
00031 extern int DebugDM_Predicate;
00032 extern int DebugDM_Iterator;
00033 extern int DebugDM_Process;
00034 extern int DebugDM_Network;
00035 extern int DebugDM_Gateway;
00036 extern int DebugDM_Adapter;
00037 extern int DebugDM_SqlLog;
00038
00039
00040 extern int printError1(DbRetVal val, char* fname, int lno, char *format, ...);
00041
00042 #define printError(a, ...) printError1(a, __FILE__, __LINE__, __VA_ARGS__)
00043
00044 enum DebugModule
00045 {
00046 DM_Alloc = 0,
00047 DM_VarAlloc,
00048 DM_Lock,
00049 DM_Transaction,
00050 DM_UndoLog,
00051 DM_RedoLog,
00052 DM_Index,
00053 DM_HashIndex,
00054 DM_SystemDatabase,
00055 DM_Database,
00056 DM_Table,
00057 DM_Predicate,
00058 DM_Iterator,
00059 DM_Process,
00060 DM_Network,
00061 DM_Gateway,
00062 DM_Adapter,
00063 DM_SqlLog
00064 };
00065 static char moduleNames[][20] =
00066 {
00067 "Alloc", "VariableAlloc", "Lock", "Trans", "UndoLog", "RedoLog", "Index",
00068 "HashIndex", "SysDb", "Db", "Table", "Predicate", "Iter", "Procmgmt",
00069 "Network", "Gateway", "Adapter", "SqlLog"
00070 };
00071
00072 extern int printDebug1(int module, char *fname, int lineno, char *format, ...);
00073
00074
00075 #ifdef DEBUG
00076 #define printDebug(a, ...) printDebug1(a, __FILE__, __LINE__, __VA_ARGS__)
00077 #else
00078 #define printDebug(...) ;
00079 #endif
00080
00081
00082
00083 #define MAX_TRACE_LOG_LENGTH 1024
00084
00085 enum LogLevel
00086 {
00087 LogOff = 0,
00088 LogFine,
00089 LogFiner,
00090 LogFinest
00091 };
00092
00093 static char levelNames[][10] =
00094 {
00095 "OFF", "FINE", "FINER", "FINEST"
00096 };
00097 #include<Mutex.h>
00098 class Logger
00099 {
00100 Mutex mutex_;
00101 int fdLog;
00102 LogLevel configLevel;
00103 public:
00104 int log(LogLevel level, char* filename, int lineNo, char *format, ...);
00105 int createLogRecord(LogLevel level, char* filename, int lineNo, char* message, char **in);
00106 DbRetVal startLogger(char *filename, bool isCreate = false);
00107 void stopLogger();
00108 };
00109
00110
00111 static Logger logger;
00112
00113 #define logFinest(logger, ...) \
00114 {\
00115 (logger).log(LogFinest, __FILE__, __LINE__, __VA_ARGS__);\
00116 };
00117
00118 #define logFiner(logger, ...) \
00119 {\
00120 (logger).log(LogFiner, __FILE__, __LINE__, __VA_ARGS__);\
00121 };
00122
00123 #define logFine(logger, ...) \
00124 {\
00125 (logger).log(LogFine, __FILE__, __LINE__, __VA_ARGS__);\
00126 };
00127
00128
00129 #endif