From: g0dil Date: Tue, 11 Aug 2009 21:02:35 +0000 (+0000) Subject: PPI: Add log label to Logger module X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=a87333050a2e284aee1a4eb142db4d45e7579d1c;p=senf.git PPI: Add log label to Logger module git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1288 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/DebugModules.cti b/PPI/DebugModules.cti index f9b90d5..9ab80f0 100644 --- a/PPI/DebugModules.cti +++ b/PPI/DebugModules.cti @@ -38,6 +38,11 @@ template prefix_ senf::ppi::module::debug::Logger::Logger() {} +template +prefix_ senf::ppi::module::debug::Logger::Logger(std::string label) + : label_ (label+"\n") +{} + //////////////////////////////////////// // private members @@ -46,9 +51,10 @@ prefix_ void senf::ppi::module::debug::Logger::v_handlePacket(Packet const & packet) { SENF_LOG_BLOCK_TPL((Stream)(Area)(Level)({ - packet.dump(log); - hexdump(packet.last().data().begin(), packet.last().data().end(),log); - })); + log << label_; + packet.dump(log); + hexdump(packet.last().data().begin(), packet.last().data().end(),log); + })); } ///////////////////////////////cti.e/////////////////////////////////////// diff --git a/PPI/DebugModules.hh b/PPI/DebugModules.hh index f382dd6..27212c6 100644 --- a/PPI/DebugModules.hh +++ b/PPI/DebugModules.hh @@ -275,9 +275,12 @@ namespace debug { SENF_PPI_MODULE(Logger); public: Logger(); + explicit Logger(std::string label); private: virtual void v_handlePacket(Packet const & packet); + + std::string label_; }; }}}} diff --git a/PPI/DebugModules.test.cc b/PPI/DebugModules.test.cc index 76a1d45..edd29b8 100644 --- a/PPI/DebugModules.test.cc +++ b/PPI/DebugModules.test.cc @@ -134,7 +134,7 @@ BOOST_AUTO_UNIT_TEST(logSink) logTarget.route(); debug::ActiveFeederSource source; - debug::Logger<> logger; + debug::Logger<> logger ("Prefix text"); ppi::connect(source,logger); senf::PacketData::byte data[] = { 0x13u, 0x24u, 0x35u };