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 #define SENF_LOG_TPL(args) \
55 SENF_LOG_BLOCK_( SENF_LOG_MERGE_PARAMETERS_TPL(BOOST_PP_SEQ_POP_BACK(args)), \
56 { log << BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(args)),args); })
58 /** \brief Enable block based on logging parameters
60 This macro is like SENF_LOG, however instead of writing a simple message, this macro allows
61 to specify a complete block of code to be executed if the log message is enabled.
63 SENF_LOG_BLOCK((parameters...)({
64 // arbitrary code using 'log' for logging
71 #define SENF_LOG_BLOCK(args) \
72 SENF_LOG_BLOCK_( SENF_LOG_MERGE_PARAMETERS(BOOST_PP_SEQ_POP_BACK(args)), \
73 BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(args)),args))
75 #define SENF_LOG_BLOCK_TPL(args) \
76 SENF_LOG_BLOCK_( SENF_LOG_MERGE_PARAMETERS_TPL(BOOST_PP_SEQ_POP_BACK(args)), \
77 BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(args)),args))
79 #define SENF_LOG_BLOCK_(parameters, block) \
81 if (parameters::compile_enabled && parameters::enabled()) { \
82 std::ostream & log (parameters::log_stream()); \
88 ///////////////////////////////hh.e////////////////////////////////////////
99 // c-file-style: "senf"
100 // indent-tabs-mode: nil
101 // ispell-local-dictionary: "american"
102 // compile-command: "scons -u test"