00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #define DEBUG_TO_FILE
00035
00036 #if defined(__ARMEL__) && !defined(DEBUG_TO_FILE)
00037
00038 # define DEBUG_TO_FILE
00039 # ifndef DEBUG_SUPPRESS_COLOR
00040 # define DEBUG_SUPPRESS_COLOR
00041 # endif
00042 #endif
00043
00044
00045
00046
00047 #ifdef PUBLIC_RELEASE
00048 # undef DEBUG
00049 # undef WARNING
00050 #endif
00051
00052
00053
00054
00055 #if defined(DEBUG) && !defined(WARNING)
00056 # define WARNING
00057 #endif
00058
00059 #if defined(WARNING) && !defined(CRITICAL)
00060 # define CRITICAL
00061 #endif
00062
00063
00064
00065 #undef SYS_DEBUG
00066 #ifdef DEBUG
00067 # define SYS_DEBUG(...) SysDebug::sysPrintMsg (\
00068 QtDebugMsg, \
00069 __PRETTY_FUNCTION__, \
00070 __VA_ARGS__)
00071 #else
00072 # define SYS_DEBUG(...) { }
00073 #endif
00074
00075
00076
00077
00078 #undef SYS_WARNING
00079 #ifdef WARNING
00080 # define SYS_WARNING(...) SysDebug::sysPrintMsg (\
00081 QtWarningMsg, \
00082 __PRETTY_FUNCTION__, \
00083 __VA_ARGS__)
00084 #else
00085 # define SYS_WARNING(...) { }
00086 #endif
00087
00088
00089
00090
00091 #undef SYS_CRITICAL
00092 #ifdef CRITICAL
00093 # define SYS_CRITICAL(...) SysDebug::sysPrintMsg (\
00094 QtCriticalMsg, \
00095 __PRETTY_FUNCTION__, \
00096 __VA_ARGS__)
00097 #else
00098 # define SYS_CRITICAL(...) { }
00099 #endif
00100
00101
00102
00103
00104
00105 #ifndef DEBUG_H
00106 #define DEBUG_H
00107
00108 #include <QTime>
00109 #include <QtDebug>
00110
00111 #ifdef DEBUG_SUPPRESS_COLOR
00112 # define TERM_RED ""
00113 # define TERM_YELLOW ""
00114 # define TERM_GREEN ""
00115 # define TERM_NORMAL ""
00116 # define TERM_BOLD ""
00117 #else
00118 # define TERM_YELLOW "\033[1;31m"
00119 # define TERM_RED "\033[1;33m"
00120 # define TERM_GREEN "\033[1;32m"
00121 # define TERM_NORMAL "\033[0;39m"
00122 # define TERM_BOLD "\033[1m"
00123 #endif
00124
00125 namespace SysDebug
00126 {
00127 void sysPrintMsg (
00128 QtMsgType type,
00129 const char *function,
00130 const char *formatstring,
00131 ...);
00132 };
00133
00134 #define SYS_STR(qstring) (TERM_BOLD+qstring+TERM_NORMAL).toLatin1().constData()
00135 #define SYS_BOOL(boolean) (boolean ? \
00136 TERM_BOLD "true" TERM_NORMAL : \
00137 TERM_BOLD "false" TERM_NORMAL)
00138
00139 #define SYS_TIME_STR SYS_STR(QTime::currentTime ().toString ("hh:mm:ss.zzz"))
00140
00141 #endif