debug.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <iostream>
00018 #include <iomanip>
00019 #include "common.h"
00020 #include "log.h"
00021
00022 #ifndef __BARRY_DEBUG_H__ // only protect the non-macro portion, in order
00023 #define __BARRY_DEBUG_H__ // to allow re-inclusion of debug.h with
00024
00025
00026 namespace Barry {
00027 extern bool __data_dump_mode__;
00028 extern std::ostream *LogStream;
00029 }
00030
00031 #endif // __BARRY_DEBUG_H__
00032
00033
00034 #define ddout(x) if(::Barry::__data_dump_mode__) { ::Barry::LogLock lock; (*::Barry::LogStream) << x << std::endl; }
00035
00036 #ifdef __DEBUG_MODE__
00037
00038 #undef dout
00039 #undef eout
00040
00041
00042 #define dout(x) if(::Barry::__data_dump_mode__) { ::Barry::LogLock lock; (*::Barry::LogStream) << x << std::endl; }
00043
00044
00045
00046 #define eout(x) { ::Barry::LogLock lock; (*::Barry::LogStream) << x << std::endl; }
00047
00048
00049 #define eeout(c, r) { ::Barry::LogLock lock; (*::Barry::LogStream) << "Sent packet:\n" << c << "\n" << "Response packet:\n" << r << "\n"; }
00050
00051
00052 #undef NDEBUG
00053 #else
00054
00055
00056 #undef dout
00057 #undef eout
00058
00059 #define dout(x)
00060 #define eout(x) { ::Barry::LogLock lock; (*::Barry::LogStream) << x << std::endl; }
00061 #define eeout(c, r) { ::Barry::LogLock lock; (*::Barry::LogStream) << "Sent packet:\n" << c << "\n" << "Response packet:\n" << r << "\n"; }
00062
00063
00064 #define NDEBUG
00065 #endif
00066
00067 #include <assert.h>
00068