menu: added new Keywords tag to .desktop files
[barry.git] / src / debug.h
blob56aa9e0d7ef9106129350fe976fde4a2222a7754
1 /*
2 Copyright (C) 2005-2013, Net Direct Inc. (http://www.netdirect.ca/)
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License in the COPYING file at the
14 root directory of this project for more details.
17 #include <iostream> // debugging only
18 #include <iomanip>
19 #include "common.h"
20 #include "log.h"
22 #ifndef __BARRY_DEBUG_H__ // only protect the non-macro portion, in order
23 #define __BARRY_DEBUG_H__ // to allow re-inclusion of debug.h with
24 // different __DEBUG_MODE__ settings
26 namespace Barry {
27 extern bool __data_dump_mode__;
28 extern std::ostream *LogStream;
31 #endif // __BARRY_DEBUG_H__
33 // data dump output - controlled by command line -v switch
34 #define ddout(x) if(::Barry::__data_dump_mode__) { ::Barry::LogLock lock; (*::Barry::LogStream) << x << std::endl; }
36 #ifdef __DEBUG_MODE__
37 // debugging on
38 #undef dout
39 #undef eout
40 #undef DEBUG_ONLY
42 // low level debug output
43 #define dout(x) if(::Barry::__data_dump_mode__) { ::Barry::LogLock lock; (*::Barry::LogStream) << x << std::endl; }
44 // #define dout(x)
46 // exception output
47 #define eout(x) { ::Barry::LogLock lock; (*::Barry::LogStream) << x << std::endl; }
49 // easy exception output
50 #define eeout(c, r) { ::Barry::LogLock lock; (*::Barry::LogStream) << "Sent packet:\n" << c << "\n" << "Response packet:\n" << r << "\n"; }
52 // For debug only variables and parameters
53 #define DEBUG_ONLY(x) x
55 // handle assert()
56 #undef NDEBUG
57 #else
59 // debugging off
60 #undef dout
61 #undef eout
62 #undef DEBUG_ONLY
64 #define dout(x)
65 #define eout(x) { ::Barry::LogLock lock; (*::Barry::LogStream) << x << std::endl; }
66 #define eeout(c, r) { ::Barry::LogLock lock; (*::Barry::LogStream) << "Sent packet:\n" << c << "\n" << "Response packet:\n" << r << "\n"; }
68 // For debug only variables and parameters
69 #define DEBUG_ONLY(x)
71 // handle assert() as well
72 #undef NDEBUG
73 #define NDEBUG
74 #endif
76 #include <assert.h>