Utils/Logger: Correct newline handling in IOStreamLogger
[senf.git] / Utils / Logger / Target.cti
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer NETwork research (NET)
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Target inline template implementation */
25
26 //#include "Target.ih"
27
28 // Custom includes
29 #include "Levels.hh"
30
31 #define prefix_ inline
32 ///////////////////////////////cti.p///////////////////////////////////////
33
34 ///////////////////////////////////////////////////////////////////////////
35 // senf::log::Target
36
37 template <class Stream>
38 prefix_ void senf::log::Target::route(action_t action, int index)
39 {
40     route(&Stream::instance(), 0, NONE::value, action, index);
41 }
42
43 template <class Stream, class Arg>
44 prefix_ void senf::log::Target::route(action_t action, int index)
45 {
46     route<Arg>(&Stream::instance(), static_cast<Arg*>(0), action, index);
47 }
48
49 template <class Stream, class Area, class Level>
50 prefix_ void senf::log::Target::route(action_t action, int index)
51 {
52     route(&Stream::instance(), &Area::instance(), Level::value, action, index);
53 }
54
55 template <class Stream>
56 prefix_ void senf::log::Target::unroute(action_t action)
57 {
58     unroute(&Stream::instance(), 0, NONE::value, action);
59 }
60
61 template <class Stream, class Arg>
62 prefix_ void senf::log::Target::unroute(action_t action)
63 {
64     unroute<Arg>(&Stream::instance(), static_cast<Arg*>(0), action);
65 }
66
67 template <class Stream, class Area, class Level>
68 prefix_ void senf::log::Target::unroute(action_t action)
69 {
70     unroute(&Stream::instance(), &Area::instance(), Level::value, action);
71 }
72
73 ////////////////////////////////////////
74 // private members
75
76 template <class Area>
77 prefix_ void senf::log::Target::route(detail::StreamBase const * stream,
78                                       detail::AreaBase const *, action_t action, int index)
79 {
80     route(stream, &Area::instance(), NONE::value, action, index);
81 }
82
83 template <class Level>
84 prefix_ void senf::log::Target::route(detail::StreamBase const * stream,
85                                       detail::LevelBase const *, action_t action, int index)
86 {
87     route(stream, 0, Level::value, action, index);
88 }
89
90 template <class Area>
91 prefix_ void senf::log::Target::unroute(detail::StreamBase const * stream,
92                                         detail::AreaBase const *, action_t action)
93 {
94     unroute(stream, &Area::instance(), NONE::value, action);
95 }
96
97 template <class Level>
98 prefix_ void senf::log::Target::unroute(detail::StreamBase const * stream,
99                                         detail::LevelBase const *, action_t action)
100 {
101     unroute(stream, 0, Level::value, action);
102 }
103
104 ///////////////////////////////////////////////////////////////////////////
105 // namespace senf::log members
106
107 template <class Stream, class Area, class Level>
108 prefix_ void senf::log::write(std::string msg)
109 {
110     TargetRegistry::instance().write(Stream::instance(), Area::instance(), Level::value, msg);
111 }
112
113 ///////////////////////////////cti.e///////////////////////////////////////
114 #undef prefix_
115
116 \f
117 // Local Variables:
118 // mode: c++
119 // fill-column: 100
120 // comment-column: 40
121 // c-file-style: "senf"
122 // indent-tabs-mode: nil
123 // ispell-local-dictionary: "american"
124 // compile-command: "scons -u test"
125 // End: