/** \brief Log received packets
This module will log all packets sent to it's input using SENF_LOG to the given log
- \a Stream, \a Area and \a level.
+ \a Stream, \a Area and \a Level.
*/
template < class Stream = log::Debug,
class Area = log::DefaultArea,
#include <algorithm>
#include <sstream>
-#define _senf_LOG_STREAM logstream
-namespace {
- std::stringstream logstream;
-}
-
#define SENF_LOG_CONF (( (senf)(log)(Debug), (_), VERBOSE ))
#include "../Packets/Packets.hh"
BOOST_AUTO_UNIT_TEST(logSink)
{
+ senf::log::StringTarget logTarget;
+ logTarget.route<senf::log::Debug,senf::log::VERBOSE>();
+
debug::ActiveFeederSource source;
debug::LogSink<> sink;
source.submit( senf::DataPacket::create(data) );
senf::ppi::run();
- BOOST_CHECK_EQUAL( logstream.str(),
- " 0000 13 24 35 .$5\n\n" );
+ BOOST_CHECK( ! logTarget.str().empty() );
}
///////////////////////////////cc.e////////////////////////////////////////
\note This class will permanently and globally change the date formating of the given
stream.
+
+ \fixme Implement more robust formatting: Find line-breaks in the message and repeat the
+ prefix (with continuation markers)
*/
class IOStreamTarget
: public Target
\hideinitializer
*/
#define SENF_LOG_BLOCK_TPL(args) \
- SENF_LOG_BLOCK_( SENF_LOG_MERGE_PARAMETERS_TPL(BOOST_PP_SEQ_POP_BACK(args)), \
- BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(args)),args))
+ SENF_LOG_BLOCK_TPL_( SENF_LOG_MERGE_PARAMETERS_TPL(BOOST_PP_SEQ_POP_BACK(args)), \
+ BOOST_PP_SEQ_ELEM(BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(args)),args))
///\}
///\}
} \
} while(0)
+#define SENF_LOG_BLOCK_TPL_(parameters, block) \
+ do { \
+ if (parameters::compileEnabled && parameters::enabled()) { \
+ std::stringstream log; \
+ do block while(0); \
+ senf::log::write<typename parameters::stream, \
+ typename parameters::area, \
+ typename parameters::level>(log.str()); \
+ } \
+ } while(0)
+
///////////////////////////////ih.e////////////////////////////////////////
#endif
to a file, to mail them to the administrator or whatever. To this end, the logging target is
passed the log message and a complete set of logging parameters (\e stream, \e area and \e
level).
+
+ \fixme optionally Integrate with Scheduler / ClockService to reduce number of gettimeofday()
+ calls.
*/
class Target : private boost::noncopyable
{