client_wrapper.hxx, socket_wrapper.hxx: reorder member initialization order
[libt2n] / src / log.hxx
1 /*
2 Copyright (C) 2006 by Intra2net AG - Gerd v. Egidy
3
4 The software in this package is distributed under the GNU General
5 Public License version 2 (with a special exception described below).
6
7 A copy of GNU General Public License (GPL) is included in this distribution,
8 in the file COPYING.GPL.
9
10 As a special exception, if other files instantiate templates or use macros
11 or inline functions from this file, or you compile this file and link it
12 with other works to produce a work based on this file, this file
13 does not by itself cause the resulting work to be covered
14 by the GNU General Public License.
15
16 However the source code for this file must still be made available
17 in accordance with section (3) of the GNU General Public License.
18
19 This exception does not invalidate any other reasons why a work based
20 on this file might be covered by the GNU General Public License.
21 */
22 #ifndef __LIBT2N_LOG
23 #define __LIBT2N_LOG
24
25 #include <iostream>
26 #include <sstream>
27
28 #define LOGGING
29
30 #ifdef LOGGING
31
32 #define LOGSTREAM(level,pipe) \
33             do { \
34                 std::ostream* streamptr; \
35                 if ((streamptr=get_logstream(level))!=NULL) \
36                     (*streamptr) << pipe << std::endl; \
37             } while (0)
38
39 #define OBJLOGSTREAM(obj,level,pipe) \
40             do { \
41                 std::ostream* streamptr; \
42                 if ((streamptr=obj.get_logstream(level))!=NULL) \
43                     (*streamptr) << pipe << std::endl; \
44             } while (0)
45
46 #define EXCEPTIONSTREAM(loglevel,exception,pipe) \
47             do { \
48                 std::ostringstream ostr; \
49                 ostr << pipe; \
50                 std::ostream* streamptr; \
51                 if ((streamptr=get_logstream(loglevel))!=NULL) \
52                     (*streamptr) << ostr.str() << std::endl; \
53                 throw exception(ostr.str()); \
54             } while (0)
55
56 #else
57
58 #define LOGSTREAM(level,pipe)
59 #define OBJLOGSTREAM(obj,level,pipe)
60 #define EXCEPTIONSTREAM(loglevel,exception,pipe)
61
62 #endif
63
64 #endif