diff --git a/PPI/DebugModules.hh b/PPI/DebugModules.hh index 58e52c64e8dcd3e6a828eca007ffc3cdbe9c29b5..67068d1e2fe277c610634646d1c83b3ea739e27d 100644 --- a/PPI/DebugModules.hh +++ b/PPI/DebugModules.hh @@ -264,7 +264,7 @@ namespace debug { /** \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, diff --git a/PPI/DebugModules.test.cc b/PPI/DebugModules.test.cc index 20101981ab48dc9f326dac7b4caea2f9c2613328..a5e518389122fb4d8b7b6ec7f0ef4de0ed0ed871 100644 --- a/PPI/DebugModules.test.cc +++ b/PPI/DebugModules.test.cc @@ -31,11 +31,6 @@ #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" @@ -136,6 +131,9 @@ BOOST_AUTO_UNIT_TEST(activeFeederSink) BOOST_AUTO_UNIT_TEST(logSink) { + senf::log::StringTarget logTarget; + logTarget.route<senf::log::Debug,senf::log::VERBOSE>(); + debug::ActiveFeederSource source; debug::LogSink<> sink; @@ -144,8 +142,7 @@ BOOST_AUTO_UNIT_TEST(logSink) 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//////////////////////////////////////// diff --git a/Utils/Logger/IOStreamTarget.hh b/Utils/Logger/IOStreamTarget.hh index 94f999948c2f7a3e0440db9592e1112306d4273f..745ee798afd6652834cf8fb1f05f56e6f7e92015 100644 --- a/Utils/Logger/IOStreamTarget.hh +++ b/Utils/Logger/IOStreamTarget.hh @@ -56,6 +56,9 @@ namespace log { \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 diff --git a/Utils/Logger/Log.hh b/Utils/Logger/Log.hh index 53f0629e93f9bbf4215dfad590595d81c1ee75f3..5c388fcb86dfd2c755369c7d8c7006242af76f0c 100644 --- a/Utils/Logger/Log.hh +++ b/Utils/Logger/Log.hh @@ -127,8 +127,8 @@ \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)) ///\} ///\} diff --git a/Utils/Logger/Log.ih b/Utils/Logger/Log.ih index 9e259c2ad0605865c373ef809910d5898550174d..95c60201ce0288749f25a0a539c4eae8f15ad60a 100644 --- a/Utils/Logger/Log.ih +++ b/Utils/Logger/Log.ih @@ -40,6 +40,17 @@ } \ } 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 diff --git a/Utils/Logger/Target.hh b/Utils/Logger/Target.hh index 9a47194aec847b10869557a488240caf35ae34fc..24b6ea3cd7a852baf15d25f4009323fcdc5a85e2 100644 --- a/Utils/Logger/Target.hh +++ b/Utils/Logger/Target.hh @@ -50,6 +50,9 @@ namespace log { 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 {