From: tho Date: Wed, 22 Jun 2011 08:38:53 +0000 (+0000) Subject: Logger: use ClockService::now() as timeBase if empty timeFormat is given for a target X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=e3179a2123ad51d0d9eb63834a581145c4f77c92;p=senf.git Logger: use ClockService::now() as timeBase if empty timeFormat is given for a target git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1793 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/VectorParser.test.cc b/senf/Packets/VectorParser.test.cc index 7ab112a..d5b1a58 100644 --- a/senf/Packets/VectorParser.test.cc +++ b/senf/Packets/VectorParser.test.cc @@ -32,6 +32,7 @@ #include #include #include +#include #define prefix_ //-///////////////////////////////////////////////////////////////////////////////////////////////// @@ -259,6 +260,7 @@ SENF_AUTO_UNIT_TEST(vectorMacro_parse) BOOST_CHECK_EQUAL( parser.vec1()[2], 0x090Au ); BOOST_CHECK_EQUAL( parser.vec2()[0], 0x0B0Cu ); BOOST_CHECK_EQUAL( parser.vec2()[1], 0x0D0Eu ); + } SENF_AUTO_UNIT_TEST(vectorMacro_create) @@ -307,7 +309,7 @@ namespace { SENF_PARSER_INHERIT(TestVectorBaseParser); - SENF_PARSER_VECTOR ( vec1 , transform(TestTransform, size1) , senf::UInt16Parser ); + SENF_PARSER_VECTOR ( vec1 , transform(TestTransform, size1) , senf::UInt8Parser ); SENF_PARSER_VECTOR ( vec2 , bytes(size2) , senf::UInt16Parser ); SENF_PARSER_FINALIZE( TestVectorDerivedParser ); @@ -317,26 +319,27 @@ namespace { SENF_AUTO_UNIT_TEST(vectorMacro_inherit) { - unsigned char data[] = { 0x05, // size1 + unsigned char data[] = { 0x08, // size1 0x04, // size2 0x01, 0x02, 0x03, 0x04, // dummy - 0x05, 0x06, // vec1[0] - 0x07, 0x08, // vec1[1] - 0x09, 0x0A, // vec1[2] + 0x05, 0x06, // vec1[0], vec1[1] + 0x07, 0x08, // vec1[2], vec1[3] + 0x09, 0x0A, // vec1[4], vec1[5] 0x0B, 0x0C, // vec2[0] 0x0D, 0x0E }; // vec2[1] senf::DataPacket p (senf::DataPacket::create(data)); TestVectorDerivedParser parser (p.data().begin(), &p.data()); - BOOST_CHECK_EQUAL( parser.vec1().size(), 3u ); + BOOST_CHECK_EQUAL( parser.vec1().size(), 6u ); BOOST_CHECK_EQUAL( parser.vec2().size(), 2u ); BOOST_CHECK_EQUAL( parser.dummy(), 0x01020304u ); - BOOST_CHECK_EQUAL( parser.vec1()[0], 0x0506u ); - BOOST_CHECK_EQUAL( parser.vec1()[1], 0x0708u ); - BOOST_CHECK_EQUAL( parser.vec1()[2], 0x090Au ); BOOST_CHECK_EQUAL( parser.vec2()[0], 0x0B0Cu ); BOOST_CHECK_EQUAL( parser.vec2()[1], 0x0D0Eu ); + boost::uint8_t c = 0x05; + BOOST_FOREACH( boost::uint8_t v, parser.vec1() ) { + BOOST_CHECK_EQUAL( v, c++ ); + } } namespace { diff --git a/senf/Utils/Logger/LogFormat.cc b/senf/Utils/Logger/LogFormat.cc index c61eb2c..b1cdd4c 100644 --- a/senf/Utils/Logger/LogFormat.cc +++ b/senf/Utils/Logger/LogFormat.cc @@ -27,7 +27,6 @@ //#include "LogFormat.ih" // Custom includes -#include #include #include #include @@ -63,7 +62,7 @@ prefix_ senf::log::detail::LogFormat::LogFormat(console::ScopedDirectory<> & dir dir.add("showStream", fty::Command(&LogFormat::showStream, this) .arg("flag","whether to display the stream in log messages", kw::default_value = true) - .doc("Set strean display in log messages.") ); + .doc("Set stream display in log messages.") ); dir.add("showLevel", fty::Command(&LogFormat::showLevel, this) .arg("flag","whether to display the log level in log messages", kw::default_value = true) @@ -106,7 +105,7 @@ prefix_ void senf::log::detail::LogFormat::timeFormat(std::string const & format timeFormat_ = format; if (format.empty()) { noformat_ = true; - timeBase_ = -1; + timeBase_ = ClockService::now(); } else { noformat_ = false; std::locale const & loc (datestream_.getloc()); @@ -124,7 +123,6 @@ prefix_ std::string senf::log::detail::LogFormat::prefix(time_type timestamp, if (showTime_) { if (noformat_) { - if (timeBase_ == -1) timeBase_ = timestamp; time_type delta (timestamp - timeBase_); datestream_ << std::setfill('0') << std::right << std::setw(10) << (delta / 1000000000ll) << '.'