Change license from LGPL to GPL version 2 + linking exception. This fixes C++ templat...
[libt2n] / src / client_wrapper.cpp
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
23 #include <client_wrapper.hxx>
24
25 namespace libt2n
26 {
27
28 const char* T2nSingletonWrapperMessages::NotInitializedMessage = "T2nSingletonWrapper used before setting initializing connection";
29
30 /// get pointer to logging stream, returns NULL if no logging needed
31 std::ostream* ConnectionWrapper::get_logstream(log_level_values level)
32 {
33     if (logstream && log_level >= level)
34         return logstream;
35     else
36         return NULL;
37 }
38
39 /// activate logging to the given stream. everything above the given level is logged.
40 void ConnectionWrapper::set_logging(std::ostream *_logstream, log_level_values _log_level)
41 {
42     log_level=_log_level;
43     logstream=_logstream;
44 }
45
46 /// always call this when you got a new connection to transfer logging settings
47 void ConnectionWrapper::set_logging_on_connection(client_connection& c)
48 {
49     if (logstream != NULL && log_level > none)
50         c.set_logging(logstream,log_level);
51 }
52
53 }