当前位置: 首页>>代码示例>>C++>>正文


C++ LogComponent::getNameForLog方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:Amosvista,项目名称:mongo,代码行数:9,代码来源:log_test.cpp

示例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() << " [");
     }
 }
开发者ID:Amosvista,项目名称:mongo,代码行数:11,代码来源:log_test.cpp

示例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() << " [");
    }
}
开发者ID:AshishSanju,项目名称:mongo,代码行数:11,代码来源:log_test.cpp

示例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);
开发者ID:Amosvista,项目名称:mongo,代码行数:31,代码来源:log_test.cpp


注:本文中的LogComponent::getNameForLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。