Replace socket_handler::fill_buffer() recursion with loop (#8389)
[libt2n] / src / log.hxx
CommitLineData
19facd85
TJ
1/*
2Copyright (C) 2006 by Intra2net AG - Gerd v. Egidy
3
4The software in this package is distributed under the GNU General
5Public License version 2 (with a special exception described below).
6
7A copy of GNU General Public License (GPL) is included in this distribution,
8in the file COPYING.GPL.
9
10As a special exception, if other files instantiate templates or use macros
11or inline functions from this file, or you compile this file and link it
12with other works to produce a work based on this file, this file
13does not by itself cause the resulting work to be covered
14by the GNU General Public License.
15
16However the source code for this file must still be made available
17in accordance with section (3) of the GNU General Public License.
18
19This exception does not invalidate any other reasons why a work based
20on this file might be covered by the GNU General Public License.
21*/
a7170401
GE
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