From 294bdbc15ed21ebe230a3aac33c535fe509c47b8 Mon Sep 17 00:00:00 2001 From: tho <tho@wiback.org> Date: Fri, 29 Feb 2008 13:07:16 +0000 Subject: [PATCH] IOStreamTarget: added loglevel to output --- Socket/Protocols/INet/INetAddressing.test.cc | 1 + Utils/Logger/IOStreamTarget.cc | 6 +++++- Utils/Logger/IOStreamTarget.hh | 2 +- Utils/Logger/Levels.hh | 2 +- Utils/Logger/Target.test.cc | 4 ++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Socket/Protocols/INet/INetAddressing.test.cc b/Socket/Protocols/INet/INetAddressing.test.cc index be3dfc8ea..0c7a7b06f 100644 --- a/Socket/Protocols/INet/INetAddressing.test.cc +++ b/Socket/Protocols/INet/INetAddressing.test.cc @@ -88,6 +88,7 @@ BOOST_AUTO_UNIT_TEST(inet6SocketAddress) { INet6SocketAddress addr; + BOOST_CHECK( ! addr ); BOOST_CHECK_EQUAL( boost::lexical_cast<std::string>(addr.address()), "::" ); BOOST_CHECK_EQUAL( addr.port(), 0u ); BOOST_CHECK_EQUAL( addr.iface(), "" ); diff --git a/Utils/Logger/IOStreamTarget.cc b/Utils/Logger/IOStreamTarget.cc index 0de7da371..6d720b563 100644 --- a/Utils/Logger/IOStreamTarget.cc +++ b/Utils/Logger/IOStreamTarget.cc @@ -38,6 +38,9 @@ /////////////////////////////////////////////////////////////////////////// // senf::log::IOStreamTarget +const char * const senf::log::IOStreamTarget::LEVELNAMES_[8] = { + "NONE", "VERBOSE", "NOTICE", "MESSAGE", "IMPORTANT", "CRITICAL", "FATAL", "DISABLED" }; + prefix_ senf::log::IOStreamTarget::IOStreamTarget(std::ostream & os) : stream_(os) { @@ -69,7 +72,8 @@ prefix_ void senf::log::IOStreamTarget::v_write(boost::posix_time::ptime timesta for (; i != i_end; ++i) { stream_ << timestamp << sep; if (area != "senf::log::DefaultArea") - stream_ << "[" << area << "] "; + stream_ << "[" << area << "]"; + stream_ << "[" << LEVELNAMES_[level] << "] "; stream_ << *i << "\n"; sep = '-'; } diff --git a/Utils/Logger/IOStreamTarget.hh b/Utils/Logger/IOStreamTarget.hh index 84e66fc50..1d976cfa9 100644 --- a/Utils/Logger/IOStreamTarget.hh +++ b/Utils/Logger/IOStreamTarget.hh @@ -82,9 +82,9 @@ namespace log { std::string const & message); std::ostream & stream_; + static char const * const LEVELNAMES_[8]; }; - }} ///////////////////////////////hh.e//////////////////////////////////////// diff --git a/Utils/Logger/Levels.hh b/Utils/Logger/Levels.hh index 89845da38..f537fce8c 100644 --- a/Utils/Logger/Levels.hh +++ b/Utils/Logger/Levels.hh @@ -41,7 +41,7 @@ namespace log { <dl><dt>VERBOSE</dt><dd>Really verbose %log messages. Messages at this level are used for internal debugging. They should be enabled only selectively within the areas currently under - inspection. The default log stream senf::log::Debug has these messages <em>disabled</em> at + inspection. The default %log stream senf::log::Debug has these messages <em>disabled</em> at compile time by default. To enable them, see \ref config.</dd> <dt>NOTICE</dt><dd>Arbitrary unimportant notice. Message which normally should be disabled diff --git a/Utils/Logger/Target.test.cc b/Utils/Logger/Target.test.cc index c896c2661..cdcaed156 100644 --- a/Utils/Logger/Target.test.cc +++ b/Utils/Logger/Target.test.cc @@ -43,8 +43,8 @@ namespace { typedef std::string result_type; std::string operator()(senf::log::Target::RoutingEntry const & entry) const { - static char const * levels[] = { "NONE", "VERBOSE", "NOTICE", "MESSAGE", - "IMPORTANT", "CRITICAL","DISABLED" }; + static char const * levels[] = { + "NONE", "VERBOSE", "NOTICE", "MESSAGE", "IMPORTANT", "CRITICAL", "FATAL", "DISABLED" }; static char const * actions[] = { "ACCEPT", "REJECT" }; std::stringstream s; s << entry.stream() << "-" << entry.area() << "-" << levels[entry.level()] << "-" -- GitLab