-// $Id: Log.test.cc 369 2007-08-01 07:51:36Z tho $
+// $Id$
//
// Copyright (C) 2007
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
//#include "Log.test.ih"
// Custom includes
-#include <sstream>
-
-#define _senf_LOG_STREAM logstream
-namespace {
- std::stringstream logstream;
-}
-
-#define SENF_LOG_CONF ((senf::log::Debug)(_)(VERBOSE))
-
-#include "Log.hh"
-#include "Defaults.hh"
-#include "Parameters.hh"
-#include "Levels.hh"
-
-#include <boost/test/auto_unit_test.hpp>
+#include "../../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
+#include "main.test.hh"
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
-namespace {
-
- template <class T>
- struct Foo
- {
- typedef int value;
- };
-
- SENF_LOG_DEF_ALIAS( LogFoo, (senf::log::Debug) (senf::log::CRITICAL) );
- SENF_LOG_DEF_STREAM( myStream, senf::log::MESSAGE, senf::log::MESSAGE, senf::log::MESSAGE );
- SENF_LOG_DEF_AREA( myArea );
-
-}
-
BOOST_AUTO_UNIT_TEST(logger)
{
+ senf::log::StringTarget target;
+
+ target.route<senf::log::Debug>();
+
+ // We cannot easily check the exact log string since that includes the current date/time
+
SENF_LOG_DEFAULT_STREAM(senf::log::Debug);
SENF_LOG_DEFAULT_AREA(senf::log::DefaultArea);
- SENF_LOG_DEFAULT_LEVEL(senf::log::NOTICE);
+ SENF_LOG_DEFAULT_LEVEL(senf::log::VERBOSE);
SENF_LOG(("Log message"));
+ BOOST_CHECK( target.str().empty() );
+ target.clear();
+
+ SENF_LOG((senf::log::VERBOSE)("Log message 2"));
+ BOOST_CHECK( target.str().empty() );
+ target.clear();
+
+ SENF_LOG((senf::log::IMPORTANT)("Important message"));
+ std::cerr << target.str();
+ BOOST_CHECK( ! target.str().empty() );
+ target.clear();
- SENF_LOG((LogFoo) ("Another log message: " << 10));
+ SENF_LOG((senf::log::test::LogCritical) ("Another log message: " << 10));
+ std::cerr << target.str();
+ BOOST_CHECK( ! target.str().empty() );
+ target.clear();
SENF_LOG_BLOCK((senf::log::Debug) (senf::log::IMPORTANT) ({
log << "Last message";
log << " continued here";
}));
-
- BOOST_CHECK_EQUAL( logstream.str(),
- "Log message\nAnother log message: 10\nLast message continued here\n" );
+ std::cerr << target.str();
+ BOOST_CHECK( ! target.str().empty() );
+ target.clear();
+
+ senf::log::test::Foo::log();
+ std::cerr << target.str();
+ BOOST_CHECK( ! target.str().empty() );
+ target.clear();
+
+ SENF_LOG((senf::log::test::Foo)("Foo area"));
+ BOOST_CHECK( target.str().empty() );
+ target.clear();
}
///////////////////////////////cc.e////////////////////////////////////////