本文整理汇总了C++中LogSink::popMatchByLevelAndText方法的典型用法代码示例。如果您正苦于以下问题:C++ LogSink::popMatchByLevelAndText方法的具体用法?C++ LogSink::popMatchByLevelAndText怎么用?C++ LogSink::popMatchByLevelAndText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogSink
的用法示例。
在下文中一共展示了LogSink::popMatchByLevelAndText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logger
TEST(Logger, Basic)
{
InterlinkedTestNodesWithSysClock nodes;
uavcan::Logger logger(nodes.a);
ASSERT_EQ(uavcan::protocol::debug::LogLevel::ERROR, logger.getLevel());
LogSink sink;
// Will fail - types are not registered
uavcan::GlobalDataTypeRegistry::instance().reset();
ASSERT_GT(0, logger.logError("foo", "Error (fail - type is not registered)"));
ASSERT_EQ(0, logger.logDebug("foo", "Debug (ignored - low logging level)"));
ASSERT_FALSE(logger.getExternalSink());
logger.setExternalSink(&sink);
ASSERT_EQ(&sink, logger.getExternalSink());
uavcan::GlobalDataTypeRegistry::instance().reset();
uavcan::DefaultDataTypeRegistrator<uavcan::protocol::debug::LogMessage> _reg1;
SubscriberWithCollector<uavcan::protocol::debug::LogMessage> log_sub(nodes.b);
ASSERT_LE(0, log_sub.start());
// Sink test
ASSERT_EQ(0, logger.logDebug("foo", "Debug (ignored due to low logging level)"));
ASSERT_TRUE(sink.msgs.empty());
sink.level = uavcan::protocol::debug::LogLevel::DEBUG;
ASSERT_EQ(0, logger.logDebug("foo", "Debug (sink only)"));
ASSERT_TRUE(sink.popMatchByLevelAndText(uavcan::protocol::debug::LogLevel::DEBUG, "foo", "Debug (sink only)"));
ASSERT_LE(0, logger.logError("foo", "Error"));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_TRUE(log_sub.collector.msg.get());
ASSERT_EQ(log_sub.collector.msg->level.value, uavcan::protocol::debug::LogLevel::ERROR);
ASSERT_EQ(log_sub.collector.msg->source, "foo");
ASSERT_EQ(log_sub.collector.msg->text, "Error");
logger.setLevel(uavcan::protocol::debug::LogLevel::DEBUG);
ASSERT_LE(0, logger.logWarning("foo", "Warning"));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_EQ(log_sub.collector.msg->level.value, uavcan::protocol::debug::LogLevel::WARNING);
ASSERT_EQ(log_sub.collector.msg->source, "foo");
ASSERT_EQ(log_sub.collector.msg->text, "Warning");
ASSERT_LE(0, logger.logInfo("foo", "Info"));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_EQ(log_sub.collector.msg->level.value, uavcan::protocol::debug::LogLevel::INFO);
ASSERT_EQ(log_sub.collector.msg->source, "foo");
ASSERT_EQ(log_sub.collector.msg->text, "Info");
ASSERT_LE(0, logger.logDebug("foo", "Debug"));
nodes.spinBoth(uavcan::MonotonicDuration::fromMSec(10));
ASSERT_EQ(log_sub.collector.msg->level.value, uavcan::protocol::debug::LogLevel::DEBUG);
ASSERT_EQ(log_sub.collector.msg->source, "foo");
ASSERT_EQ(log_sub.collector.msg->text, "Debug");
ASSERT_TRUE(sink.popMatchByLevelAndText(uavcan::protocol::debug::LogLevel::ERROR, "foo", "Error"));
ASSERT_TRUE(sink.popMatchByLevelAndText(uavcan::protocol::debug::LogLevel::WARNING, "foo", "Warning"));
ASSERT_TRUE(sink.popMatchByLevelAndText(uavcan::protocol::debug::LogLevel::INFO, "foo", "Info"));
ASSERT_TRUE(sink.popMatchByLevelAndText(uavcan::protocol::debug::LogLevel::DEBUG, "foo", "Debug"));
}