本文整理汇总了C++中LogComponent::getNameForLog方法的典型用法代码示例。如果您正苦于以下问题:C++ LogComponent::getNameForLog方法的具体用法?C++ LogComponent::getNameForLog怎么用?C++ LogComponent::getNameForLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogComponent
的用法示例。
在下文中一共展示了LogComponent::getNameForLog方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Log names of all components should have the same length.
TEST_F(LogTestUnadornedEncoder, LogComponentNameForLog) {
size_t defaultNameForLogLength = componentDefault.getNameForLog().toString().length();
ASSERT_NOT_EQUALS(0U, defaultNameForLogLength);
for (int i = 0; i < int(LogComponent::kNumLogComponents); ++i) {
LogComponent component = static_cast<LogComponent::Value>(i);
ASSERT_EQUALS(defaultNameForLogLength, component.getNameForLog().toString().length());
}
}
示例2: ctx
// Non-default log component short name should always be logged.
TEST_F(LogTestUnadornedEncoder, MessageEventDetailsEncoderLogComponent) {
Date_t d = Date_t::now();
StringData ctx("WHAT", StringData::LiteralTag());
StringData msg("HUH", StringData::LiteralTag());
for (int i = 0; i < int(LogComponent::kNumLogComponents); ++i) {
LogComponent component = static_cast<LogComponent::Value>(i);
testEncodedLogLine(MessageEventEphemeral(d, LogSeverity::Info(), component, ctx, msg),
str::stream() << " I " << component.getNameForLog() << " [");
}
}
示例3: testEncodedLogLine
// Non-default log component short name should always be logged.
TEST_F(LogTestUnadornedEncoder, MessageEventDetailsEncoderLogComponent) {
Date_t d = Date_t::now();
const auto ctx = "WHAT"_sd;
const auto msg = "HUH"_sd;
for (int i = 0; i < int(LogComponent::kNumLogComponents); ++i) {
LogComponent component = static_cast<LogComponent::Value>(i);
testEncodedLogLine(MessageEventEphemeral(d, LogSeverity::Info(), component, ctx, msg),
str::stream() << " I " << component.getNameForLog() << " [");
}
}
示例4: testEncodedLogLine
for (int i = 0; i < int(LogComponent::kNumLogComponents); ++i) {
LogComponent component = static_cast<LogComponent::Value>(i);
testEncodedLogLine(MessageEventEphemeral(d, LogSeverity::Info(), component, ctx, msg),
str::stream() << " I " << component.getNameForLog() << " [");
}
}
// Tests pass through of log component:
// log macros -> LogStreamBuilder -> MessageEventEphemeral -> MessageEventDetailsEncoder
TEST_F(LogTestDetailsEncoder, ) {
globalLogDomain()->setMinimumLoggedSeverity(LogSeverity::Log());
// Default log component short name should not appear in detailed log line.
MONGO_LOG_COMPONENT(0, componentDefault) << "This is logged";
ASSERT_EQUALS(1U, _logLines.size());
ASSERT_NOT_EQUALS(_logLines[0].find(componentDefault.getNameForLog().toString()),
std::string::npos);
// Non-default log component short name should appear in detailed log line.
_logLines.clear();
MONGO_LOG_COMPONENT(0, componentA) << "This is logged";
ASSERT_EQUALS(1U, _logLines.size());
ASSERT_NOT_EQUALS(_logLines[0].find(componentA.getNameForLog().toString()),
std::string::npos);
// MONGO_LOG_COMPONENT2 - only the first component is sent to LogStreamBuilder.
_logLines.clear();
MONGO_LOG_COMPONENT2(0, componentA, componentB) << "This is logged";
ASSERT_EQUALS(1U, _logLines.size());
ASSERT_NOT_EQUALS(_logLines[0].find(componentA.getNameForLog().toString()),
std::string::npos);