util: Generalize logger backend support
This commit introduces a public API change for changing log
destinations.
Refs: #3782
Change-Id: I329c60f510d9493af5959b34eea93b81e15fe698
diff --git a/tests/unit/util/logging.t.cpp b/tests/unit/util/logging.t.cpp
index 5be163a..e051cce 100644
--- a/tests/unit/util/logging.t.cpp
+++ b/tests/unit/util/logging.t.cpp
@@ -156,7 +156,7 @@
private:
std::unordered_map<std::string, LogLevel> m_oldEnabledLevel;
- shared_ptr<std::ostream> m_oldDestination;
+ boost::shared_ptr<boost::log::sinks::sink> m_oldDestination;
};
BOOST_AUTO_TEST_SUITE(Util)
@@ -624,7 +624,7 @@
logFromModule1();
auto os2 = make_shared<output_test_stream>();
- Logging::setDestination(os2);
+ Logging::setDestination(Logging::makeDefaultStreamDestination(os2));
weak_ptr<output_test_stream> os2weak(os2);
os2.reset();
@@ -646,6 +646,16 @@
BOOST_CHECK(os2weak.expired());
}
+BOOST_AUTO_TEST_CASE(SetNullptrDestination)
+{
+ Logging::setDestination(nullptr);
+ logFromModule1();
+
+ Logging::flush();
+ BOOST_CHECK(os.is_equal(""));
+ // The default Boost.Log output is still expected
+}
+
BOOST_AUTO_TEST_SUITE_END() // TestLogging
BOOST_AUTO_TEST_SUITE_END() // Util