From: g0dil Date: Thu, 5 Feb 2009 11:23:26 +0000 (+0000) Subject: Utils/Logger: Move log formatting into LogFromat mixin class X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=07b8c0784c854893cd1a4ecb9aa051a625ebe17e;p=senf.git Utils/Logger: Move log formatting into LogFromat mixin class Utils/Logger: Add more formatting options to SyslogUDPTarget git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1099 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Utils/Logger/IOStreamTarget.cc b/Utils/Logger/IOStreamTarget.cc index 6441cf8..b020e34 100644 --- a/Utils/Logger/IOStreamTarget.cc +++ b/Utils/Logger/IOStreamTarget.cc @@ -24,16 +24,13 @@ \brief IOStreamTarget non-inline non-template implementation */ #include "IOStreamTarget.hh" -#include "IOStreamTarget.ih" +//#include "IOStreamTarget.ih" // Custom includes -#include #include #include #include #include -#include -#include "../Scheduler/ClockService.hh" //#include "IOStreamTarget.mpp" #define prefix_ @@ -42,32 +39,6 @@ /////////////////////////////////////////////////////////////////////////// // senf::log::IOStreamTarget -prefix_ senf::log::IOStreamTarget::IOStreamTarget(std::ostream & os) - : stream_ (os), tag_ (detail::getDefaultTag()), noformat_ (false), showTime_ (true), - showStream_ (false), showLevel_ (true), showArea_ (true), timeBase_ (-1) -{ - std::locale const & loc (datestream_.getloc()); - datestream_.imbue( std::locale( - loc, new boost::posix_time::time_facet("%Y-%m-%d %H:%M:%S.%f-0000")) ); - -} - -prefix_ void senf::log::IOStreamTarget::timeFormat(std::string const & format) -{ - if (format.empty()) { - noformat_ = true; - timeBase_ = -1; - } else { - noformat_ = false; - std::locale const & loc (datestream_.getloc()); - datestream_.imbue( std::locale( - loc, new boost::posix_time::time_facet(format.c_str())) ); - } -} - -//////////////////////////////////////// -// private members - prefix_ void senf::log::IOStreamTarget::v_write(time_type timestamp, std::string const & stream, std::string const & area, unsigned level, @@ -77,9 +48,11 @@ prefix_ void senf::log::IOStreamTarget::v_write(time_type timestamp, boost::trim_right(m); detail::quoteNonPrintable(m); - if (tag_.empty() && !showTime_ && !showStream_ && !showLevel_ && !showArea_) + if (isPlainFormat()) stream_ << m << std::endl; else { + std::string const & prf (prefix(timestamp, stream, area, level)); + typedef boost::char_separator Separator; typedef boost::tokenizer Tokenizer; Separator separator ("\n"); @@ -87,51 +60,12 @@ prefix_ void senf::log::IOStreamTarget::v_write(time_type timestamp, Tokenizer::iterator i (tokenizer.begin()); Tokenizer::iterator const i_end (tokenizer.end()); - if (showTime_) { - if (noformat_) { - if (timeBase_ == -1) timeBase_ = timestamp; - time_type delta (timestamp - timeBase_); - datestream_ << std::setfill('0') << std::setw(10) - << (delta / 1000000000ll) << '.' - << std::setfill('0') << std::setw(9) - << (delta % 1000000000ll); - } - else - datestream_ << senf::ClockService::abstime(timestamp); - datestream_ << ' '; - } - if (!tag_.empty()) - datestream_ << tag_ << ": "; - if (showStream_) - datestream_ << '[' << stream << "] "; - if (showLevel_) - datestream_ << '[' << LEVELNAMES[level] << "] "; - if (showArea_ && area != "senf::log::DefaultArea") - datestream_ << '[' << area << "] "; - for (; i != i_end; ++i) - stream_ << datestream_.str() << *i << "\n"; + stream_ << prf << *i << "\n"; stream_ << std::flush; - datestream_.str(""); } } -/////////////////////////////////////////////////////////////////////////// - -prefix_ void senf::log::detail::quoteNonPrintable(std::string & s) -{ - for (std::string::iterator i (s.begin()); i != s.end(); ++i) - if (*i < ' ' && *i != '\n') - *i = ' '; -} - -prefix_ std::string senf::log::detail::getDefaultTag() -{ - std::stringstream ss; - ss << ::program_invocation_short_name << '[' << ::getpid() << ']'; - return ss.str(); -} - ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "IOStreamTarget.mpp" diff --git a/Utils/Logger/IOStreamTarget.cci b/Utils/Logger/IOStreamTarget.cci index 1943027..8e55b74 100644 --- a/Utils/Logger/IOStreamTarget.cci +++ b/Utils/Logger/IOStreamTarget.cci @@ -23,37 +23,16 @@ /** \file \brief IOStreamTarget inline non-template implementation */ -#include "IOStreamTarget.ih" +//#include "IOStreamTarget.ih" // Custom includes #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// -prefix_ void senf::log::IOStreamTarget::showTime(bool flag) -{ - showTime_ = flag; -} - -prefix_ void senf::log::IOStreamTarget::showStream(bool flag) -{ - showStream_ = flag; -} - -prefix_ void senf::log::IOStreamTarget::showLevel(bool flag) -{ - showLevel_ = flag; -} - -prefix_ void senf::log::IOStreamTarget::showArea(bool flag) -{ - showArea_ = flag; -} - -prefix_ void senf::log::IOStreamTarget::tag(std::string const & tag) -{ - tag_ = tag; -} +prefix_ senf::log::IOStreamTarget::IOStreamTarget(std::ostream & os) + : stream_ (os) +{} ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_ diff --git a/Utils/Logger/IOStreamTarget.hh b/Utils/Logger/IOStreamTarget.hh index 8aa5829..bb1c0d5 100644 --- a/Utils/Logger/IOStreamTarget.hh +++ b/Utils/Logger/IOStreamTarget.hh @@ -30,6 +30,7 @@ #include #include #include "Target.hh" +#include "LogFormat.hh" //#include "IOStreamTarget.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -49,7 +50,7 @@ namespace log { \ingroup targets */ class IOStreamTarget - : public Target + : public Target, private detail::LogFormat { public: /////////////////////////////////////////////////////////////////////////// @@ -61,26 +62,12 @@ namespace log { ///@} /////////////////////////////////////////////////////////////////////////// - void showTime(bool flag = true); ///< Enable or disable output of time field - void showStream(bool flag = true); ///< Enable or disable output of stream field - void showLevel(bool flag = true); ///< Enable or disable output of log level - void showArea(bool flag = true); ///< Enable or disable output of log area - - void timeFormat(std::string const & format); - ///< Set time format - /**< The date formatting is set using the Boost.DateTime - date_facet, e.g. - \code - target.timeFormat("%Y%m%d %H:%M:%S"); - \endcode - If the \c timeFormat is set to the empty string, the - time is written out as unformatted ClockService value. - - By default, the date-time will be written in extended - ISO format. - \param[in] format Date/Time format string */ - - void tag(std::string const & tag); + using detail::LogFormat::showTime; + using detail::LogFormat::showStream; + using detail::LogFormat::showLevel; + using detail::LogFormat::showArea; + using detail::LogFormat::timeFormat; + using detail::LogFormat::tag; protected: void v_write(time_type timestamp, std::string const & stream, @@ -90,15 +77,6 @@ namespace log { private: std::ostream & stream_; - std::string tag_; - std::stringstream datestream_; - bool noformat_; - bool showTime_; - bool showStream_; - bool showLevel_; - bool showArea_; - - time_type timeBase_; }; }} diff --git a/Utils/Logger/LogFormat.cc b/Utils/Logger/LogFormat.cc new file mode 100644 index 0000000..217c376 --- /dev/null +++ b/Utils/Logger/LogFormat.cc @@ -0,0 +1,123 @@ +// $Id$ +// +// Copyright (C) 2009 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief LogFormat non-inline non-template implementation */ + +#include "LogFormat.hh" +//#include "LogFormat.ih" + +// Custom includes +#include +#include +#include +#include +#include "../Scheduler/ClockService.hh" + +//#include "LogFormat.mpp" +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + +prefix_ senf::log::detail::LogFormat::LogFormat() + : tag_ (detail::getDefaultTag()), noformat_ (false), showTime_ (true), + showStream_ (false), showLevel_ (true), showArea_ (true), timeBase_ (-1) +{ + std::locale const & loc (datestream_.getloc()); + datestream_.imbue( std::locale( + loc, new boost::posix_time::time_facet("%Y-%m-%d %H:%M:%S.%f-0000")) ); +} + +prefix_ void senf::log::detail::LogFormat::timeFormat(std::string const & format) +{ + if (format.empty()) { + noformat_ = true; + timeBase_ = -1; + } else { + noformat_ = false; + std::locale const & loc (datestream_.getloc()); + datestream_.imbue( std::locale( + loc, new boost::posix_time::time_facet(format.c_str())) ); + } +} + +prefix_ std::string senf::log::detail::LogFormat::prefix(time_type timestamp, + std::string const & stream, + std::string const & area, + unsigned level) +{ + datestream_.str(""); + + if (showTime_) { + if (noformat_) { + if (timeBase_ == -1) timeBase_ = timestamp; + time_type delta (timestamp - timeBase_); + datestream_ << std::setfill('0') << std::setw(10) + << (delta / 1000000000ll) << '.' + << std::setfill('0') << std::setw(9) + << (delta % 1000000000ll); + } + else + datestream_ << senf::ClockService::abstime(timestamp); + datestream_ << ' '; + } + if (!tag_.empty()) + datestream_ << tag_ << ": "; + if (showStream_) + datestream_ << '[' << stream << "] "; + if (showLevel_) + datestream_ << '[' << LEVELNAMES[level] << "] "; + if (showArea_ && area != "senf::log::DefaultArea") + datestream_ << '[' << area << "] "; + + return datestream_.str(); +} + +/////////////////////////////////////////////////////////////////////////// + +prefix_ void senf::log::detail::quoteNonPrintable(std::string & s) +{ + for (std::string::iterator i (s.begin()); i != s.end(); ++i) + if (*i < ' ' && *i != '\n') + *i = '?'; +} + +prefix_ std::string senf::log::detail::getDefaultTag() +{ + std::stringstream ss; + ss << ::program_invocation_short_name << '[' << ::getpid() << ']'; + return ss.str(); +} + +///////////////////////////////cc.e//////////////////////////////////////// +#undef prefix_ +//#include "LogFormat.mpp" + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: diff --git a/Utils/Logger/IOStreamTarget.ih b/Utils/Logger/LogFormat.cci similarity index 56% rename from Utils/Logger/IOStreamTarget.ih rename to Utils/Logger/LogFormat.cci index 2718bca..7d9c083 100644 --- a/Utils/Logger/IOStreamTarget.ih +++ b/Utils/Logger/LogFormat.cci @@ -1,6 +1,6 @@ // $Id$ // -// Copyright (C) 2008 +// Copyright (C) 2009 // Fraunhofer Institute for Open Communication Systems (FOKUS) // Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund @@ -21,26 +21,48 @@ // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \file - \brief IOStreamTarget internal header */ + \brief LogFormat inline non-template implementation */ -#ifndef IH_SENF_Utils_Logger_IOStreamTarget_ -#define IH_SENF_Utils_Logger_IOStreamTarget_ 1 +//#include "LogFormat.ih" // Custom includes -///////////////////////////////ih.p//////////////////////////////////////// +#define prefix_ inline +///////////////////////////////cci.p/////////////////////////////////////// -namespace senf { -namespace log { -namespace detail { +prefix_ void senf::log::detail::LogFormat::showTime(bool flag) +{ + showTime_ = flag; +} - void quoteNonPrintable(std::string & s); - std::string getDefaultTag(); +prefix_ void senf::log::detail::LogFormat::showStream(bool flag) +{ + showStream_ = flag; +} -}}} +prefix_ void senf::log::detail::LogFormat::showLevel(bool flag) +{ + showLevel_ = flag; +} -///////////////////////////////ih.e//////////////////////////////////////// -#endif +prefix_ void senf::log::detail::LogFormat::showArea(bool flag) +{ + showArea_ = flag; +} + +prefix_ void senf::log::detail::LogFormat::tag(std::string const & tag) +{ + tag_ = tag; +} + +prefix_ bool senf::log::detail::LogFormat::isPlainFormat() + const +{ + return tag_.empty() && !showTime_ && !showStream_ && !showLevel_ && !showArea_; +} + +///////////////////////////////cci.e/////////////////////////////////////// +#undef prefix_ // Local Variables: diff --git a/Utils/Logger/LogFormat.hh b/Utils/Logger/LogFormat.hh new file mode 100644 index 0000000..2c4ff00 --- /dev/null +++ b/Utils/Logger/LogFormat.hh @@ -0,0 +1,102 @@ +// $Id$ +// +// Copyright (C) 2009 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Stefan Bund +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief LogFormat public header */ + +#ifndef HH_SENF_Utils_Logger_LogFormat_ +#define HH_SENF_Utils_Logger_LogFormat_ 1 + +// Custom includes +#include +#include "Target.hh" + +//#include "LogFormat.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +namespace senf { +namespace log { +namespace detail { + + class LogFormat + { + public: + LogFormat(); + + void showTime(bool flag = true); ///< Enable or disable output of time field + void showStream(bool flag = true); ///< Enable or disable output of stream field + void showLevel(bool flag = true); ///< Enable or disable output of log level + void showArea(bool flag = true); ///< Enable or disable output of log area + + void timeFormat(std::string const & format); + ///< Set time format + /**< The date formatting is set using the Boost.DateTime + date_facet, e.g. + \code + target.timeFormat("%Y%m%d %H:%M:%S"); + \endcode + If the \c timeFormat is set to the empty string, the + time is written out as unformatted ClockService value. + + By default, the date-time will be written in extended + ISO format. + \param[in] format Date/Time format string */ + + void tag(std::string const & tag); ///< Set tag (log line prefix) + + protected: + std::string prefix(time_type timestamp, std::string const & stream, + std::string const & area, unsigned level); + bool isPlainFormat() const; + + private: + std::string tag_; + std::stringstream datestream_; + bool noformat_; + bool showTime_; + bool showStream_; + bool showLevel_; + bool showArea_; + time_type timeBase_; + }; + + void quoteNonPrintable(std::string & s); + std::string getDefaultTag(); + +}}} + +///////////////////////////////hh.e//////////////////////////////////////// +#include "LogFormat.cci" +//#include "LogFormat.ct" +//#include "LogFormat.cti" +#endif + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: diff --git a/Utils/Logger/SyslogUDPTarget.cc b/Utils/Logger/SyslogUDPTarget.cc index f4888f2..0538fe0 100644 --- a/Utils/Logger/SyslogUDPTarget.cc +++ b/Utils/Logger/SyslogUDPTarget.cc @@ -30,60 +30,24 @@ #include #include #include -#include "../../Socket/Protocols/INet/ConnectedUDPSocketHandle.hh" -#include "IOStreamTarget.hh" //#include "SyslogUDPTarget.mpp" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -prefix_ senf::log::SyslogUDPTarget::SyslogUDPTarget(senf::INet4Address const & target, - int facility) - : facility_ (facility), tag_ (detail::getDefaultTag()), - handle_ ( senf::ConnectedUDPv4ClientSocketHandle(senf::INet4SocketAddress(target, 514u)) ), - showStream_ (false), showLevel_ (false), showArea_ (true) -{} - -prefix_ senf::log::SyslogUDPTarget::SyslogUDPTarget(senf::INet4SocketAddress const & target, - int facility) - : facility_ (facility), tag_ (detail::getDefaultTag()), - handle_ ( senf::ConnectedUDPv4ClientSocketHandle(target) ), - showStream_ (false), showLevel_ (false), showArea_ (true) -{} - -prefix_ senf::log::SyslogUDPTarget::SyslogUDPTarget(senf::INet6Address const & target, - int facility) - : facility_ (facility), tag_ (detail::getDefaultTag()), - handle_ ( senf::ConnectedUDPv6ClientSocketHandle(senf::INet6SocketAddress(target, 514u)) ), - showStream_ (false), showLevel_ (false), showArea_ (true) -{} - -prefix_ senf::log::SyslogUDPTarget::SyslogUDPTarget(senf::INet6SocketAddress const & target, - int facility) - : facility_ (facility), tag_ (detail::getDefaultTag()), - handle_ ( senf::ConnectedUDPv6ClientSocketHandle(target) ), - showStream_ (false), showLevel_ (false), showArea_ (true) -{} - prefix_ void senf::log::SyslogUDPTarget::v_write(time_type timestamp, std::string const & stream, std::string const & area, unsigned level, std::string const & message) { - std::stringstream prefix; - - prefix << '<' << (facility_ | senf::log::SyslogTarget::LEVELMAP[level]) << "> "; - if (!tag_.empty()) - prefix << tag_ << ": "; - if (showStream_) - prefix << '[' << stream << "] "; - if (showLevel_) - prefix << '[' << LEVELNAMES[level] << "] "; - if (showArea_ && area != "senf::log::DefaultArea") - prefix << '[' << area << "] "; std::string m (message); boost::trim_right(m); detail::quoteNonPrintable(m); + std::stringstream prfstream; + prfstream << '<' << (facility_ | senf::log::SyslogTarget::LEVELMAP[level]) << "> " + << prefix(timestamp, stream, area, level); + std::string const & prf (prfstream.str()); + typedef boost::char_separator Separator; typedef boost::tokenizer Tokenizer; Separator separator ("\n"); @@ -92,10 +56,10 @@ prefix_ void senf::log::SyslogUDPTarget::v_write(time_type timestamp, std::strin Tokenizer::iterator const i_end (tokenizer.end()); std::string line; - unsigned sz (896-prefix.str().size()); + unsigned sz (896-prf.size()); for (; i != i_end; ++i) for (unsigned j (0); j < i->size(); j += sz) { - line = prefix.str(); + line = prf; line += std::string(*i, j, sz); handle_.write(line); } diff --git a/Utils/Logger/SyslogUDPTarget.cci b/Utils/Logger/SyslogUDPTarget.cci index 24f63d2..4078e3d 100644 --- a/Utils/Logger/SyslogUDPTarget.cci +++ b/Utils/Logger/SyslogUDPTarget.cci @@ -26,29 +26,34 @@ //#include "SyslogUDPTarget.ih" // Custom includes +#include "../../Socket/Protocols/INet/ConnectedUDPSocketHandle.hh" #define prefix_ inline ///////////////////////////////cci.p/////////////////////////////////////// -prefix_ void senf::log::SyslogUDPTarget::showStream(bool flag) -{ - showStream_ = flag; -} +prefix_ senf::log::SyslogUDPTarget::SyslogUDPTarget(senf::INet4Address const & target, + int facility) + : facility_ (facility), + handle_ ( senf::ConnectedUDPv4ClientSocketHandle(senf::INet4SocketAddress(target, 514u)) ) +{} -prefix_ void senf::log::SyslogUDPTarget::showLevel(bool flag) -{ - showLevel_ = flag; -} +prefix_ senf::log::SyslogUDPTarget::SyslogUDPTarget(senf::INet4SocketAddress const & target, + int facility) + : facility_ (facility), + handle_ ( senf::ConnectedUDPv4ClientSocketHandle(target) ) +{} -prefix_ void senf::log::SyslogUDPTarget::showArea(bool flag) -{ - showArea_ = flag; -} +prefix_ senf::log::SyslogUDPTarget::SyslogUDPTarget(senf::INet6Address const & target, + int facility) + : facility_ (facility), + handle_ ( senf::ConnectedUDPv6ClientSocketHandle(senf::INet6SocketAddress(target, 514u)) ) +{} -prefix_ void senf::log::SyslogUDPTarget::tag(std::string const & tag) -{ - tag_ = tag; -} +prefix_ senf::log::SyslogUDPTarget::SyslogUDPTarget(senf::INet6SocketAddress const & target, + int facility) + : facility_ (facility), + handle_ ( senf::ConnectedUDPv6ClientSocketHandle(target) ) +{} ///////////////////////////////cci.e/////////////////////////////////////// #undef prefix_ diff --git a/Utils/Logger/SyslogUDPTarget.hh b/Utils/Logger/SyslogUDPTarget.hh index 6b7e269..c3d8b15 100644 --- a/Utils/Logger/SyslogUDPTarget.hh +++ b/Utils/Logger/SyslogUDPTarget.hh @@ -28,6 +28,7 @@ // Custom includes #include "SyslogTarget.hh" +#include "LogFormat.hh" #include "../../Socket/Protocols/INet/INetAddressing.hh" #include "../../Socket/ClientSocketHandle.hh" #include "../../Socket/FramingPolicy.hh" @@ -87,7 +88,7 @@ namespace log { daemon to skip the \c HEADER part. */ class SyslogUDPTarget - : public Target + : public Target, private detail::LogFormat { public: /////////////////////////////////////////////////////////////////////////// @@ -105,11 +106,12 @@ namespace log { ///@} /////////////////////////////////////////////////////////////////////////// - void showStream(bool flag = true); - void showLevel(bool flag = true); - void showArea(bool flag = true); - - void tag(std::string const & tag); + using detail::LogFormat::showTime; + using detail::LogFormat::showStream; + using detail::LogFormat::showLevel; + using detail::LogFormat::showArea; + using detail::LogFormat::timeFormat; + using detail::LogFormat::tag; private: void v_write(time_type timestamp, std::string const & stream, @@ -117,15 +119,11 @@ namespace log { std::string const & message); int facility_; - std::string tag_; typedef senf::ClientSocketHandle< senf::MakeSocketPolicy< senf::DatagramFramingPolicy, senf::ConnectedCommunicationPolicy, senf::WriteablePolicy>::policy > Handle; Handle handle_; - bool showStream_; - bool showLevel_; - bool showArea_; }; }} diff --git a/Utils/Logger/SyslogUDPTarget.test.cc b/Utils/Logger/SyslogUDPTarget.test.cc index 65e9c8c..9dfeeb1 100644 --- a/Utils/Logger/SyslogUDPTarget.test.cc +++ b/Utils/Logger/SyslogUDPTarget.test.cc @@ -45,6 +45,8 @@ BOOST_AUTO_UNIT_TEST(syslogUDPTarget) senf::INet4SocketAddress(senf::INet4Address::Loopback, 23444u)); udplog.tag(""); + udplog.showTime(false); + udplog.showLevel(false); udplog.route(); SENF_LOG(("Test message")); @@ -54,10 +56,12 @@ BOOST_AUTO_UNIT_TEST(syslogUDPTarget) BOOST_CHECK_EQUAL( server.read(), "<13> Test message" ); BOOST_CHECK_EQUAL( server.read(), "<13> Line 2" ); + udplog.timeFormat(""); + udplog.showTime(); SENF_LOG(("Very long message: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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