4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
24 \brief Log public header */
30 #include <boost/preprocessor/seq/size.hpp>
31 #include <boost/preprocessor/dec.hpp>
32 #include <boost/preprocessor/seq/elem.hpp>
33 #include <boost/preprocessor/seq/pop_back.hpp>
34 #include "Parameters.hh"
37 ///////////////////////////////hh.p////////////////////////////////////////
39 /** \brief Write log message
41 This macro will write it's last argument to the log stream. The last argument must be an
42 expression which will be placed after a streaming \c operator<< (like
43 <i>some-log-sttream</i> \c << <i>last-macro-arg</i>).
45 SENF_LOG((parameters...)("log message " << args << ...));
50 #define SENF_LOG(args) \
51 SENF_LOG_BLOCK_( SENF_LOG_MERGE_PARAMETERS(BOOST_PP_SEQ_POP_BACK(args)), \
52 { log << BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(args)),args); })
54 /** \brief Enable block based on logging parameters
56 This macro is like SENF_LOG, however instead of writing a simple message, this macro allows
57 to specify a complete block of code to be executed if the log message is enabled.
59 SENF_LOG_BLOCK((parameters...)({
60 // arbitrary code using 'log' for logging
67 #define SENF_LOG_BLOCK(args) \
68 SENF_LOG_BLOCK_( SENF_LOG_MERGE_PARAMETERS(BOOST_PP_SEQ_POP_BACK(args)), \
69 BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(args)),args))
71 #define SENF_LOG_BLOCK_(parameters, block) \
73 if (parameters::compile_enabled && parameters::enabled()) { \
74 std::ostream & log (parameters::log_stream()); \
80 ///////////////////////////////hh.e////////////////////////////////////////
91 // c-file-style: "senf"
92 // indent-tabs-mode: nil
93 // ispell-local-dictionary: "american"
94 // compile-command: "scons -u test"