Skip to content
Snippets Groups Projects
Commit 2866f806 authored by Niclas Esser's avatar Niclas Esser
Browse files

Use valid logging backend instead -> prevent segmentation fault of following tests

parent 5ec4628f
Branches
Tags
1 merge request!41Avoid acquiring dada buffers when the buffer is full (writer) or when it is...
Pipeline #230943 passed
......@@ -12,16 +12,27 @@ namespace test {
TEST(SetLogLevel, UPPER)
{
// setting log elvel with mixed upper / lower caps should work
std::stringstream ss;
boost::shared_ptr<sink_t> streamSink = boost::log::add_console_log(ss);
// Set up a logging sink with the stringstream as the target
auto backend = boost::make_shared<boost::log::sinks::text_ostream_backend>();
backend->add_stream(boost::shared_ptr<std::ostream>(&ss, boost::null_deleter()));
backend->auto_flush(true);
auto sink = boost::make_shared<sink_t>(backend);
boost::log::core::get()->add_sink(sink);
// Set log level
set_log_level("INfO");
BOOST_LOG_TRIVIAL(debug) << "Should not be in log";
EXPECT_EQ(ss.rdbuf()->in_avail(), 0);
EXPECT_EQ(ss.str().size(), 0); // No debug messages
BOOST_LOG_TRIVIAL(info) << "Should be in log";
EXPECT_GT(ss.rdbuf()->in_avail(), 0);
EXPECT_GT(ss.str().size(), 0); // Info messages appear in the log
// Remove the sink to clean up
boost::log::core::get()->remove_sink(sink);
}
TEST(SetLogLevel, ThrowOnUnknownLevel)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment