libt2n: (gerd) client callbacks
[libt2n] / src / log.hxx
CommitLineData
a7170401
GE
1/***************************************************************************
2 * Copyright (C) 2006 by Gerd v. Egidy *
3 * gve@intra2net.com *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Lesser General Public License version *
7 * 2.1 as published by the Free Software Foundation. *
8 * *
9 * This library 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. See the *
12 * GNU Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
19#ifndef __LIBT2N_LOG
20#define __LIBT2N_LOG
21
22#include <iostream>
23#include <sstream>
24
25#define LOGGING
26
27#ifdef LOGGING
28
29#define LOGSTREAM(level,pipe) \
30 do { \
31 std::ostream* streamptr; \
32 if ((streamptr=get_logstream(level))!=NULL) \
33 (*streamptr) << pipe << std::endl; \
34 } while (0)
35
36#define OBJLOGSTREAM(obj,level,pipe) \
37 do { \
38 std::ostream* streamptr; \
39 if ((streamptr=obj.get_logstream(level))!=NULL) \
40 (*streamptr) << pipe << std::endl; \
41 } while (0)
42
43#define EXCEPTIONSTREAM(loglevel,exception,pipe) \
44 do { \
45 std::ostringstream ostr; \
46 ostr << pipe; \
47 std::ostream* streamptr; \
48 if ((streamptr=get_logstream(loglevel))!=NULL) \
49 (*streamptr) << ostr.str() << std::endl; \
50 throw exception(ostr.str()); \
51 } while (0)
52
53#else
54
55#define LOGSTREAM(level,pipe)
56#define OBJLOGSTREAM(obj,level,pipe)
57#define EXCEPTIONSTREAM(loglevel,exception,pipe)
58
59#endif
60
61#endif