diff options
-rwxr-xr-x | buildscripts/errorcodes.py | 4 | ||||
-rw-r--r-- | src/mongo/logger/logv2_appender.h | 7 | ||||
-rw-r--r-- | src/mongo/logv2/attributes.cpp | 2 | ||||
-rw-r--r-- | src/mongo/logv2/attributes.h | 2 | ||||
-rw-r--r-- | src/mongo/logv2/bson_formatter.cpp | 5 | ||||
-rw-r--r-- | src/mongo/logv2/constants.h | 2 | ||||
-rw-r--r-- | src/mongo/logv2/json_formatter.cpp | 13 | ||||
-rw-r--r-- | src/mongo/logv2/log.h | 142 | ||||
-rw-r--r-- | src/mongo/logv2/log_detail.cpp | 6 | ||||
-rw-r--r-- | src/mongo/logv2/log_detail.h | 10 | ||||
-rw-r--r-- | src/mongo/logv2/log_source.h | 16 | ||||
-rw-r--r-- | src/mongo/logv2/log_test_v2.cpp | 158 | ||||
-rw-r--r-- | src/mongo/logv2/logv2_bm.cpp | 11 |
13 files changed, 152 insertions, 226 deletions
diff --git a/buildscripts/errorcodes.py b/buildscripts/errorcodes.py index d56fadb009a..1cbaba1f04e 100755 --- a/buildscripts/errorcodes.py +++ b/buildscripts/errorcodes.py @@ -42,13 +42,15 @@ list_files = False # pylint: disable=invalid-name def parse_source_files(callback): """Walk MongoDB sourcefiles and invoke a callback for each AssertLocation found.""" - quick = [r"assert", r"Exception", r"ErrorCodes::Error"] + quick = [r"assert", r"Exception", r"ErrorCodes::Error", r"LOGV2"] patterns = [ re.compile(r"(?:u|m(?:sg)?)asser(?:t|ted)(?:NoTrace)?\s*\(\s*(\d+)", re.MULTILINE), re.compile(r"(?:DB|Assertion)Exception\s*[({]\s*(\d+)", re.MULTILINE), re.compile(r"fassert(?:Failed)?(?:WithStatus)?(?:NoTrace)?(?:StatusOK)?\s*\(\s*(\d+)", re.MULTILINE), + re.compile(r"LOGV2(?:_INFO|_WARNING|_ERROR|_FATAL|_DEBUG)?(?:_OPTIONS)?\s*\(\s*(\d+)", + re.MULTILINE), re.compile(r"ErrorCodes::Error\s*[({]\s*(\d+)", re.MULTILINE) ] diff --git a/src/mongo/logger/logv2_appender.h b/src/mongo/logger/logv2_appender.h index e5a677099cb..c6050e9b4a2 100644 --- a/src/mongo/logger/logv2_appender.h +++ b/src/mongo/logger/logv2_appender.h @@ -82,8 +82,8 @@ public: if (event.isTruncatable() && message.size() > maxSizeKB * 1024) { logv2::detail::doLog( + 0, logv2::LogSeverity::cast(event.getSeverity().toInt()), - StringData{}, logv2::LogOptions{ logComponentV1toV2(event.getComponent()), _domain, @@ -97,13 +97,10 @@ public: } logv2::detail::doLog( - + 0, // We need to cast from the v1 logging severity to the equivalent v2 severity logv2::LogSeverity::cast(event.getSeverity().toInt()), - // stable id doesn't exist in logv1 - StringData{}, - // Similarly, we need to transcode the options. They don't offer a cast // operator, so we need to do some metaprogramming on the types. logv2::LogOptions{ diff --git a/src/mongo/logv2/attributes.cpp b/src/mongo/logv2/attributes.cpp index b5b2c4f4d7b..dc76a88fb8f 100644 --- a/src/mongo/logv2/attributes.cpp +++ b/src/mongo/logv2/attributes.cpp @@ -63,7 +63,7 @@ const boost::log::attribute_name& tags() { return attr; } -const boost::log::attribute_name& stableId() { +const boost::log::attribute_name& id() { static const boost::log::attribute_name attr("id"); return attr; } diff --git a/src/mongo/logv2/attributes.h b/src/mongo/logv2/attributes.h index 26c9a109db3..a69e097aaf6 100644 --- a/src/mongo/logv2/attributes.h +++ b/src/mongo/logv2/attributes.h @@ -42,7 +42,7 @@ const boost::log::attribute_name& component(); const boost::log::attribute_name& timeStamp(); const boost::log::attribute_name& threadName(); const boost::log::attribute_name& tags(); -const boost::log::attribute_name& stableId(); +const boost::log::attribute_name& id(); const boost::log::attribute_name& message(); const boost::log::attribute_name& attributes(); diff --git a/src/mongo/logv2/bson_formatter.cpp b/src/mongo/logv2/bson_formatter.cpp index 3e5bda3f0cc..9ef3017b815 100644 --- a/src/mongo/logv2/bson_formatter.cpp +++ b/src/mongo/logv2/bson_formatter.cpp @@ -124,10 +124,7 @@ void BSONFormatter::operator()(boost::log::record_view const& rec, extract<LogComponent>(attributes::component(), rec).get().getNameForLog()); builder.append(constants::kContextFieldName, extract<StringData>(attributes::threadName(), rec).get()); - auto stable_id = extract<StringData>(attributes::stableId(), rec).get(); - if (!stable_id.empty()) { - builder.append(constants::kStableIdFieldName, stable_id); - } + builder.append(constants::kIdFieldName, extract<int32_t>(attributes::id(), rec).get()); detail::NameExtractor nameExtractor; attrs.apply(nameExtractor); diff --git a/src/mongo/logv2/constants.h b/src/mongo/logv2/constants.h index 3cebb6fba04..5c702e723e8 100644 --- a/src/mongo/logv2/constants.h +++ b/src/mongo/logv2/constants.h @@ -40,7 +40,7 @@ constexpr StringData kTimestampFieldName = "t"_sd; constexpr StringData kSeverityFieldName = "s"_sd; constexpr StringData kComponentFieldName = "c"_sd; constexpr StringData kContextFieldName = "ctx"_sd; -constexpr StringData kStableIdFieldName = "id"_sd; +constexpr StringData kIdFieldName = "id"_sd; constexpr StringData kMessageFieldName = "msg"_sd; constexpr StringData kAttributesFieldName = "attr"_sd; constexpr StringData kTagsFieldName = "tags"_sd; diff --git a/src/mongo/logv2/json_formatter.cpp b/src/mongo/logv2/json_formatter.cpp index 4d8bed8d5c8..8da5c268519 100644 --- a/src/mongo/logv2/json_formatter.cpp +++ b/src/mongo/logv2/json_formatter.cpp @@ -138,12 +138,6 @@ void JSONFormatter::operator()(boost::log::record_view const& rec, // Build a JSON object for the user attributes. const auto& attrs = extract<TypeErasedAttributeStorage>(attributes::attributes(), rec).get(); - std::string id; - auto stable_id = extract<StringData>(attributes::stableId(), rec).get(); - if (!stable_id.empty()) { - id = fmt::format("\"{}\":\"{}\",", constants::kStableIdFieldName, stable_id); - } - StringData severity = extract<LogSeverity>(attributes::severity(), rec).get().toStringDataCompact(); StringData component = @@ -166,7 +160,7 @@ void JSONFormatter::operator()(boost::log::record_view const& rec, R"("{}":"{}"{: <{}})" // severity with padding for the comma R"("{}":"{}"{: <{}})" // component with padding for the comma R"("{}":"{}",)" // context - R"({})" // optional stable id + R"("{}":{},)" // id R"("{}":")", // message // timestamp constants::kTimestampFieldName, @@ -184,8 +178,9 @@ void JSONFormatter::operator()(boost::log::record_view const& rec, // context constants::kContextFieldName, extract<StringData>(attributes::threadName(), rec).get(), - // stable id - id, + // id + constants::kIdFieldName, + extract<int32_t>(attributes::id(), rec).get(), // message constants::kMessageFieldName); diff --git a/src/mongo/logv2/log.h b/src/mongo/logv2/log.h index 9a313535ce2..308874b482a 100644 --- a/src/mongo/logv2/log.h +++ b/src/mongo/logv2/log.h @@ -68,140 +68,70 @@ const ::mongo::logv2::LogComponent MongoLogV2DefaultComponent_component = namespace mongo { -#define LOGV2_IMPL(SEVERITY, ID, OPTIONS, MESSAGE, ...) \ - logv2::detail::doLog(SEVERITY, ID, OPTIONS, FMT_STRING(MESSAGE), ##__VA_ARGS__) +#define LOGV2_IMPL(ID, SEVERITY, OPTIONS, MESSAGE, ...) \ + logv2::detail::doLog(ID, SEVERITY, OPTIONS, FMT_STRING(MESSAGE), ##__VA_ARGS__) -#define LOGV2(MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Log(), \ - ::mongo::StringData{}, \ +#define LOGV2(ID, MESSAGE, ...) \ + LOGV2_IMPL(ID, \ + ::mongo::logv2::LogSeverity::Log(), \ ::mongo::logv2::LogOptions{}, \ MESSAGE, \ ##__VA_ARGS__) -#define LOGV2_OPTIONS(OPTIONS, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Log(), \ - ::mongo::StringData{}, \ - OPTIONS, \ - MESSAGE, \ - ##__VA_ARGS__) - -#define LOGV2_STABLE(ID, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Log(), \ - ID, \ - ::mongo::logv2::LogOptions{}, \ - MESSAGE, \ - ##__VA_ARGS__) - -#define LOGV2_OPTIONS_STABLE(ID, OPTIONS, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Log(), ID, OPTIONS, MESSAGE, ##__VA_ARGS__) - -#define LOGV2_INFO(MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Info(), \ - ::mongo::StringData{}, \ - ::mongo::logv2::LogOptions{}, \ - MESSAGE, \ - ##__VA_ARGS__) - -#define LOGV2_INFO_OPTIONS(OPTIONS, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Info(), \ - ::mongo::StringData{}, \ - OPTIONS, \ - MESSAGE, \ - ##__VA_ARGS__) +#define LOGV2_OPTIONS(ID, OPTIONS, MESSAGE, ...) \ + LOGV2_IMPL(ID, ::mongo::logv2::LogSeverity::Log(), OPTIONS, MESSAGE, ##__VA_ARGS__) -#define LOGV2_INFO_STABLE(ID, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Info(), \ - ID, \ +#define LOGV2_INFO(ID, MESSAGE, ...) \ + LOGV2_IMPL(ID, \ + ::mongo::logv2::LogSeverity::Info(), \ ::mongo::logv2::LogOptions{}, \ MESSAGE, \ ##__VA_ARGS__) -#define LOGV2_INFO_OPTIONS_STABLE(ID, OPTIONS, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Info(), ID, OPTIONS, MESSAGE, ##__VA_ARGS__) - -#define LOGV2_WARNING(MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Warning(), \ - ::mongo::StringData{}, \ - ::mongo::logv2::LogOptions{}, \ - MESSAGE, \ - ##__VA_ARGS__) - -#define LOGV2_WARNING_OPTIONS(OPTIONS, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Warning(), \ - ::mongo::StringData{}, \ - OPTIONS, \ - MESSAGE, \ - ##__VA_ARGS__) +#define LOGV2_INFO_OPTIONS(ID, OPTIONS, MESSAGE, ...) \ + LOGV2_IMPL(ID, ::mongo::logv2::LogSeverity::Info(), OPTIONS, MESSAGE, ##__VA_ARGS__) -#define LOGV2_WARNING_STABLE(ID, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Warning(), \ - ID, \ +#define LOGV2_WARNING(ID, MESSAGE, ...) \ + LOGV2_IMPL(ID, \ + ::mongo::logv2::LogSeverity::Warning(), \ ::mongo::logv2::LogOptions{}, \ MESSAGE, \ ##__VA_ARGS__) -#define LOGV2_WARNING_OPTIONS_STABLE(ID, OPTIONS, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Warning(), ID, OPTIONS, MESSAGE, ##__VA_ARGS__) - -#define LOGV2_ERROR(MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Error(), \ - ::mongo::StringData{}, \ - ::mongo::logv2::LogOptions{}, \ - MESSAGE, \ - ##__VA_ARGS__) - -#define LOGV2_ERROR_OPTIONS(OPTIONS, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Error(), \ - ::mongo::StringData{}, \ - OPTIONS, \ - MESSAGE, \ - ##__VA_ARGS__) +#define LOGV2_WARNING_OPTIONS(ID, OPTIONS, MESSAGE, ...) \ + LOGV2_IMPL(ID, ::mongo::logv2::LogSeverity::Warning(), OPTIONS, MESSAGE, ##__VA_ARGS__) -#define LOGV2_ERROR_STABLE(ID, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Error(), \ - ID, \ +#define LOGV2_ERROR(ID, MESSAGE, ...) \ + LOGV2_IMPL(ID, \ + ::mongo::logv2::LogSeverity::Error(), \ ::mongo::logv2::LogOptions{}, \ MESSAGE, \ ##__VA_ARGS__) -#define LOGV2_ERROR_OPTIONS_STABLE(ID, OPTIONS, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Error(), ID, OPTIONS, MESSAGE, ##__VA_ARGS__) +#define LOGV2_ERROR_OPTIONS(ID, OPTIONS, MESSAGE, ...) \ + LOGV2_IMPL(ID, ::mongo::logv2::LogSeverity::Error(), OPTIONS, MESSAGE, ##__VA_ARGS__) -#define LOGV2_FATAL(FASSERT_ID, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Severe(), \ - ::mongo::StringData{}, \ +#define LOGV2_FATAL(ID, MESSAGE, ...) \ + LOGV2_IMPL(ID, \ + ::mongo::logv2::LogSeverity::Severe(), \ ::mongo::logv2::LogOptions{}, \ MESSAGE, \ ##__VA_ARGS__) -#define LOGV2_FATAL_OPTIONS(FASSERT_ID, OPTIONS, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Severe(), \ - ::mongo::StringData{}, \ - OPTIONS, \ - MESSAGE, \ - ##__VA_ARGS__) - -#define LOGV2_FATAL_STABLE(ID, FASSERT_ID, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Severe(), \ - ID, \ - ::mongo::logv2::LogOptions{}, \ - MESSAGE, \ - ##__VA_ARGS__) - -#define LOGV2_FATAL_OPTIONS_STABLE(ID, FASSERT_ID, OPTIONS, MESSAGE, ...) \ - LOGV2_IMPL(::mongo::logv2::LogSeverity::Severe(), ID, OPTIONS, MESSAGE, ##__VA_ARGS__) +#define LOGV2_FATAL_OPTIONS(ID, OPTIONS, MESSAGE, ...) \ + LOGV2_IMPL(ID, ::mongo::logv2::LogSeverity::Severe(), OPTIONS, MESSAGE, ##__VA_ARGS__) -#define LOGV2_DEBUG_OPTIONS(DLEVEL, OPTIONS, MESSAGE, ...) \ - do { \ - auto severity = ::mongo::logv2::LogSeverity::Debug(DLEVEL); \ - if (::mongo::logv2::LogManager::global().getGlobalSettings().shouldLog( \ - MongoLogV2DefaultComponent_component, severity)) { \ - LOGV2_IMPL(severity, ::mongo::StringData{}, OPTIONS, MESSAGE, ##__VA_ARGS__); \ - } \ +#define LOGV2_DEBUG_OPTIONS(ID, DLEVEL, OPTIONS, MESSAGE, ...) \ + do { \ + auto severity = ::mongo::logv2::LogSeverity::Debug(DLEVEL); \ + if (::mongo::logv2::LogManager::global().getGlobalSettings().shouldLog( \ + MongoLogV2DefaultComponent_component, severity)) { \ + LOGV2_IMPL(ID, severity, OPTIONS, MESSAGE, ##__VA_ARGS__); \ + } \ } while (false) -#define LOGV2_DEBUG(DLEVEL, MESSAGE, ...) \ - LOGV2_DEBUG_OPTIONS(DLEVEL, ::mongo::logv2::LogOptions{}, MESSAGE, ##__VA_ARGS__) +#define LOGV2_DEBUG(ID, DLEVEL, MESSAGE, ...) \ + LOGV2_DEBUG_OPTIONS(ID, DLEVEL, ::mongo::logv2::LogOptions{}, MESSAGE, ##__VA_ARGS__) } // namespace mongo diff --git a/src/mongo/logv2/log_detail.cpp b/src/mongo/logv2/log_detail.cpp index 579ba741e67..8ed9b5abe58 100644 --- a/src/mongo/logv2/log_detail.cpp +++ b/src/mongo/logv2/log_detail.cpp @@ -42,13 +42,13 @@ namespace mongo { namespace logv2 { namespace detail { -void doLogImpl(LogSeverity const& severity, - StringData stable_id, +void doLogImpl(int32_t id, + LogSeverity const& severity, LogOptions const& options, StringData message, TypeErasedAttributeStorage const& attrs) { auto& source = options.domain().internal().source(); - auto record = source.open_record(severity, options.component(), options.tags(), stable_id); + auto record = source.open_record(id, severity, options.component(), options.tags()); if (record) { record.attribute_values().insert( attributes::message(), diff --git a/src/mongo/logv2/log_detail.h b/src/mongo/logv2/log_detail.h index e5ffbc48fd8..420d4f11bd8 100644 --- a/src/mongo/logv2/log_detail.h +++ b/src/mongo/logv2/log_detail.h @@ -40,23 +40,23 @@ namespace mongo { namespace logv2 { namespace detail { -void doLogImpl(LogSeverity const& severity, - StringData stable_id, +void doLogImpl(int32_t id, + LogSeverity const& severity, LogOptions const& options, StringData message, TypeErasedAttributeStorage const& attrs); template <typename S, typename... Args> -void doLog(LogSeverity const& severity, - StringData stable_id, +void doLog(int32_t id, + LogSeverity const& severity, LogOptions const& options, S const& message, const fmt::internal::named_arg<Args, char>&... args) { auto attributes = makeAttributeStorage(args...); auto msg = static_cast<fmt::string_view>(message); - doLogImpl(severity, stable_id, options, StringData(msg.data(), msg.size()), attributes); + doLogImpl(id, severity, options, StringData(msg.data(), msg.size()), attributes); } } // namespace detail diff --git a/src/mongo/logv2/log_source.h b/src/mongo/logv2/log_source.h index 7510a68d352..108f623ad99 100644 --- a/src/mongo/logv2/log_source.h +++ b/src/mongo/logv2/log_source.h @@ -60,12 +60,12 @@ public: _severity(LogSeverity::Log()), _component(LogComponent::kDefault), _tags(LogTag::kNone), - _id(StringData{}) { + _id(-1) { add_attribute_unlocked(attributes::domain(), _domain); add_attribute_unlocked(attributes::severity(), _severity); add_attribute_unlocked(attributes::component(), _component); add_attribute_unlocked(attributes::tags(), _tags); - add_attribute_unlocked(attributes::stableId(), _id); + add_attribute_unlocked(attributes::id(), _id); add_attribute_unlocked(attributes::timeStamp(), boost::log::attributes::make_function([]() { return Date_t::now(); })); @@ -74,16 +74,16 @@ public: boost::log::attributes::make_function([]() { return getThreadName(); })); } - boost::log::record open_record(LogSeverity severity, + boost::log::record open_record(int32_t id, + LogSeverity severity, LogComponent component, - LogTag tags, - StringData stable_id) { + LogTag tags) { // Perform a quick check first if (this->core()->get_logging_enabled()) { _severity.set(severity); _component.set(component); _tags.set(tags); - _id.set(stable_id); + _id.set(id); return Base::open_record_unlocked(); } else return boost::log::record(); @@ -94,7 +94,7 @@ public: _severity.set(LogSeverity::Log()); _component.set(LogComponent::kDefault); _tags.set(LogTag::kNone); - _id.set(StringData{}); + _id.set(-1); } private: @@ -102,7 +102,7 @@ private: boost::log::attributes::mutable_constant<LogSeverity> _severity; boost::log::attributes::mutable_constant<LogComponent> _component; boost::log::attributes::mutable_constant<LogTag> _tags; - boost::log::attributes::mutable_constant<StringData> _id; + boost::log::attributes::mutable_constant<int32_t> _id; }; diff --git a/src/mongo/logv2/log_test_v2.cpp b/src/mongo/logv2/log_test_v2.cpp index 7c24dbd9b69..9e34c5f84c9 100644 --- a/src/mongo/logv2/log_test_v2.cpp +++ b/src/mongo/logv2/log_test_v2.cpp @@ -193,7 +193,7 @@ public: sink->set_formatter(PlainFormatter()); boost::log::core::get()->add_sink(sink); - LOGV2("log during init"); + LOGV2(20001, "log during init"); ASSERT(lines.back() == "log during init"); boost::log::core::get()->remove_sink(sink); @@ -213,47 +213,47 @@ TEST_F(LogTestV2, Basic) { BSONObjBuilder builder; fmt::memory_buffer buffer; - LOGV2("test"); + LOGV2(20002, "test"); ASSERT_EQUALS(lines.back(), "test"); - LOGV2_DEBUG(-2, "test debug"); + LOGV2_DEBUG(20063, -2, "test debug"); ASSERT_EQUALS(lines.back(), "test debug"); - LOGV2("test {}", "name"_attr = 1); + LOGV2(20003, "test {}", "name"_attr = 1); ASSERT_EQUALS(lines.back(), "test 1"); - LOGV2("test {:d}", "name"_attr = 2); + LOGV2(20004, "test {:d}", "name"_attr = 2); ASSERT_EQUALS(lines.back(), "test 2"); - LOGV2("test {}", "name"_attr = "char*"); + LOGV2(20005, "test {}", "name"_attr = "char*"); ASSERT_EQUALS(lines.back(), "test char*"); - LOGV2("test {}", "name"_attr = std::string("std::string")); + LOGV2(20006, "test {}", "name"_attr = std::string("std::string")); ASSERT_EQUALS(lines.back(), "test std::string"); - LOGV2("test {}", "name"_attr = "StringData"_sd); + LOGV2(20007, "test {}", "name"_attr = "StringData"_sd); ASSERT_EQUALS(lines.back(), "test StringData"); - LOGV2_OPTIONS({LogTag::kStartupWarnings}, "test"); + LOGV2_OPTIONS(20064, {LogTag::kStartupWarnings}, "test"); ASSERT_EQUALS(lines.back(), "test"); TypeWithBSON t(1.0, 2.0); - LOGV2("{} custom formatting", "name"_attr = t); + LOGV2(20008, "{} custom formatting", "name"_attr = t); ASSERT_EQUALS(lines.back(), t.toString() + " custom formatting"); TypeWithoutBSON t2(1.0, 2.0); - LOGV2("{} custom formatting, no bson", "name"_attr = t2); + LOGV2(20009, "{} custom formatting, no bson", "name"_attr = t2); ASSERT_EQUALS(lines.back(), t.toString() + " custom formatting, no bson"); TypeWithOnlyStringSerialize t3(1.0, 2.0); - LOGV2("{}", "name"_attr = t3); + LOGV2(20010, "{}", "name"_attr = t3); buffer.clear(); t3.serialize(buffer); ASSERT_EQUALS(lines.back(), fmt::to_string(buffer)); // Serialize should be preferred when both are available TypeWithBothStringFormatters t4; - LOGV2("{}", "name"_attr = t4); + LOGV2(20011, "{}", "name"_attr = t4); buffer.clear(); t4.serialize(buffer); ASSERT_EQUALS(lines.back(), fmt::to_string(buffer)); @@ -303,7 +303,7 @@ TEST_F(LogTestV2, Types) { auto test = [&](auto value) { text.clear(); - LOGV2("{}", "name"_attr = value); + LOGV2(20012, "{}", "name"_attr = value); ASSERT_EQUALS(text.back(), fmt::format("{}", value)); validateJSON(value); @@ -336,7 +336,7 @@ TEST_F(LogTestV2, Types) { auto test = [&](auto value) { text.clear(); - LOGV2("{}", "name"_attr = value); + LOGV2(20013, "{}", "name"_attr = value); // Floats are formatted as double ASSERT_EQUALS(text.back(), fmt::format("{}", static_cast<double>(value))); validateJSON(value); @@ -356,13 +356,13 @@ TEST_F(LogTestV2, Types) { }; bool b = true; - LOGV2("bool {}", "name"_attr = b); + LOGV2(20014, "bool {}", "name"_attr = b); ASSERT_EQUALS(text.back(), "bool true"); validateJSON(b); ASSERT(lastBSONElement().Bool() == b); char c = 1; - LOGV2("char {}", "name"_attr = c); + LOGV2(20015, "char {}", "name"_attr = c); ASSERT_EQUALS(text.back(), "char 1"); validateJSON(static_cast<uint8_t>( c)); // cast, boost property_tree will try and parse as ascii otherwise @@ -389,20 +389,20 @@ TEST_F(LogTestV2, Types) { // enums enum UnscopedEnum { UnscopedEntry }; - LOGV2("{}", "name"_attr = UnscopedEntry); + LOGV2(20076, "{}", "name"_attr = UnscopedEntry); auto expectedUnscoped = static_cast<std::underlying_type_t<UnscopedEnum>>(UnscopedEntry); ASSERT_EQUALS(text.back(), std::to_string(expectedUnscoped)); validateJSON(expectedUnscoped); ASSERT_EQUALS(lastBSONElement().Number(), expectedUnscoped); enum class ScopedEnum { Entry = -1 }; - LOGV2("{}", "name"_attr = ScopedEnum::Entry); + LOGV2(20077, "{}", "name"_attr = ScopedEnum::Entry); auto expectedScoped = static_cast<std::underlying_type_t<ScopedEnum>>(ScopedEnum::Entry); ASSERT_EQUALS(text.back(), std::to_string(expectedScoped)); validateJSON(expectedScoped); ASSERT_EQUALS(lastBSONElement().Number(), expectedScoped); - LOGV2("{}", "name"_attr = UnscopedEntryWithToString); + LOGV2(20078, "{}", "name"_attr = UnscopedEntryWithToString); ASSERT_EQUALS(text.back(), toString(UnscopedEntryWithToString)); validateJSON(toString(UnscopedEntryWithToString)); ASSERT_EQUALS(lastBSONElement().String(), toString(UnscopedEntryWithToString)); @@ -410,25 +410,25 @@ TEST_F(LogTestV2, Types) { // string types const char* c_str = "a c string"; - LOGV2("c string {}", "name"_attr = c_str); + LOGV2(20016, "c string {}", "name"_attr = c_str); ASSERT_EQUALS(text.back(), "c string a c string"); validateJSON(std::string(c_str)); ASSERT_EQUALS(lastBSONElement().String(), c_str); char* c_str2 = const_cast<char*>("non-const"); - LOGV2("c string {}", "name"_attr = c_str2); + LOGV2(20017, "c string {}", "name"_attr = c_str2); ASSERT_EQUALS(text.back(), "c string non-const"); validateJSON(std::string(c_str2)); ASSERT_EQUALS(lastBSONElement().String(), c_str2); std::string str = "a std::string"; - LOGV2("std::string {}", "name"_attr = str); + LOGV2(20018, "std::string {}", "name"_attr = str); ASSERT_EQUALS(text.back(), "std::string a std::string"); validateJSON(str); ASSERT_EQUALS(lastBSONElement().String(), str); StringData str_data = "a StringData"_sd; - LOGV2("StringData {}", "name"_attr = str_data); + LOGV2(20019, "StringData {}", "name"_attr = str_data); ASSERT_EQUALS(text.back(), "StringData a StringData"); validateJSON(str_data.toString()); ASSERT_EQUALS(lastBSONElement().String(), str_data); @@ -440,7 +440,7 @@ TEST_F(LogTestV2, Types) { builder.append("double"_sd, 1.0); builder.append("str"_sd, str_data); BSONObj bsonObj = builder.obj(); - LOGV2("bson {}", "name"_attr = bsonObj); + LOGV2(20020, "bson {}", "name"_attr = bsonObj); ASSERT(text.back() == std::string("bson ") + bsonObj.jsonString(JsonStringFormat::ExtendedRelaxedV2_0_0)); ASSERT(mongo::fromjson(json.back()) @@ -457,7 +457,7 @@ TEST_F(LogTestV2, Types) { arrBuilder.append("second"_sd); arrBuilder.append("third"_sd); BSONArray bsonArr = arrBuilder.arr(); - LOGV2("{}", "name"_attr = bsonArr); + LOGV2(20021, "{}", "name"_attr = bsonArr); ASSERT_EQUALS(text.back(), bsonArr.jsonString(JsonStringFormat::ExtendedRelaxedV2_0_0, 0, true)); ASSERT(mongo::fromjson(json.back()) @@ -469,7 +469,7 @@ TEST_F(LogTestV2, Types) { ASSERT(lastBSONElement().Obj().woCompare(bsonArr) == 0); // BSONElement - LOGV2("bson element {}", "name"_attr = bsonObj.getField("int32"_sd)); + LOGV2(20022, "bson element {}", "name"_attr = bsonObj.getField("int32"_sd)); ASSERT(text.back() == std::string("bson element ") + bsonObj.getField("int32"_sd).toString()); ASSERT(mongo::fromjson(json.back()) .getField(kAttributesFieldName) @@ -483,7 +483,7 @@ TEST_F(LogTestV2, Types) { // Date_t Date_t date = Date_t::now(); - LOGV2("Date_t {}", "name"_attr = date); + LOGV2(20023, "Date_t {}", "name"_attr = date); ASSERT_EQUALS(text.back(), std::string("Date_t ") + date.toString()); ASSERT_EQUALS( mongo::fromjson(json.back()).getField(kAttributesFieldName).Obj().getField("name").Date(), @@ -491,7 +491,7 @@ TEST_F(LogTestV2, Types) { ASSERT_EQUALS(lastBSONElement().Date(), date); // Decimal128 - LOGV2("Decimal128 {}", "name"_attr = Decimal128::kPi); + LOGV2(20024, "Decimal128 {}", "name"_attr = Decimal128::kPi); ASSERT_EQUALS(text.back(), std::string("Decimal128 ") + Decimal128::kPi.toString()); ASSERT(mongo::fromjson(json.back()) .getField(kAttributesFieldName) @@ -503,7 +503,7 @@ TEST_F(LogTestV2, Types) { // OID OID oid = OID::gen(); - LOGV2("OID {}", "name"_attr = oid); + LOGV2(20025, "OID {}", "name"_attr = oid); ASSERT_EQUALS(text.back(), std::string("OID ") + oid.toString()); ASSERT_EQUALS( mongo::fromjson(json.back()).getField(kAttributesFieldName).Obj().getField("name").OID(), @@ -512,7 +512,7 @@ TEST_F(LogTestV2, Types) { // Timestamp Timestamp ts = Timestamp::max(); - LOGV2("Timestamp {}", "name"_attr = ts); + LOGV2(20026, "Timestamp {}", "name"_attr = ts); ASSERT_EQUALS(text.back(), std::string("Timestamp ") + ts.toString()); ASSERT_EQUALS(mongo::fromjson(json.back()) .getField(kAttributesFieldName) @@ -524,7 +524,7 @@ TEST_F(LogTestV2, Types) { // UUID UUID uuid = UUID::gen(); - LOGV2("UUID {}", "name"_attr = uuid); + LOGV2(20027, "UUID {}", "name"_attr = uuid); ASSERT_EQUALS(text.back(), std::string("UUID ") + uuid.toString()); ASSERT_EQUALS(UUID::parse(mongo::fromjson(json.back()) .getField(kAttributesFieldName) @@ -535,7 +535,7 @@ TEST_F(LogTestV2, Types) { ASSERT_EQUALS(UUID::parse(lastBSONElement().Obj()), uuid); // boost::optional - LOGV2("boost::optional empty {}", "name"_attr = boost::optional<bool>()); + LOGV2(20028, "boost::optional empty {}", "name"_attr = boost::optional<bool>()); ASSERT_EQUALS(text.back(), std::string("boost::optional empty ") + constants::kNullOptionalString.toString()); @@ -546,14 +546,15 @@ TEST_F(LogTestV2, Types) { .isNull()); ASSERT(lastBSONElement().isNull()); - LOGV2("boost::optional<bool> {}", "name"_attr = boost::optional<bool>(true)); + LOGV2(20029, "boost::optional<bool> {}", "name"_attr = boost::optional<bool>(true)); ASSERT_EQUALS(text.back(), std::string("boost::optional<bool> true")); ASSERT_EQUALS( mongo::fromjson(json.back()).getField(kAttributesFieldName).Obj().getField("name").Bool(), true); ASSERT_EQUALS(lastBSONElement().Bool(), true); - LOGV2("boost::optional<boost::optional<bool>> {}", + LOGV2(20030, + "boost::optional<boost::optional<bool>> {}", "name"_attr = boost::optional<boost::optional<bool>>(boost::optional<bool>(true))); ASSERT_EQUALS(text.back(), std::string("boost::optional<boost::optional<bool>> true")); ASSERT_EQUALS( @@ -562,7 +563,8 @@ TEST_F(LogTestV2, Types) { ASSERT_EQUALS(lastBSONElement().Bool(), true); TypeWithBSON withBSON(1.0, 2.0); - LOGV2("boost::optional<TypeWithBSON> {}", + LOGV2(20031, + "boost::optional<TypeWithBSON> {}", "name"_attr = boost::optional<TypeWithBSON>(withBSON)); ASSERT_EQUALS(text.back(), std::string("boost::optional<TypeWithBSON> ") + withBSON.toString()); ASSERT(mongo::fromjson(json.back()) @@ -574,7 +576,8 @@ TEST_F(LogTestV2, Types) { ASSERT(lastBSONElement().Obj().woCompare(withBSON.toBSON()) == 0); TypeWithoutBSON withoutBSON(1.0, 2.0); - LOGV2("boost::optional<TypeWithBSON> {}", + LOGV2(20032, + "boost::optional<TypeWithBSON> {}", "name"_attr = boost::optional<TypeWithoutBSON>(withoutBSON)); ASSERT_EQUALS(text.back(), std::string("boost::optional<TypeWithBSON> ") + withoutBSON.toString()); @@ -585,7 +588,7 @@ TEST_F(LogTestV2, Types) { // Duration Milliseconds ms{12345}; - LOGV2("Duration {}", "name"_attr = ms); + LOGV2(20033, "Duration {}", "name"_attr = ms); ASSERT_EQUALS(text.back(), std::string("Duration ") + ms.toString()); ASSERT_EQUALS(mongo::fromjson(json.back()) .getField(kAttributesFieldName) @@ -605,30 +608,31 @@ TEST_F(LogTestV2, TextFormat) { sink->set_formatter(TextFormatter()); attach(sink); - LOGV2_OPTIONS({LogTag::kNone}, "warning"); + LOGV2_OPTIONS(20065, {LogTag::kNone}, "warning"); ASSERT(lines.back().rfind("** WARNING: warning") == std::string::npos); - LOGV2_OPTIONS({LogTag::kStartupWarnings}, "warning"); + LOGV2_OPTIONS(20066, {LogTag::kStartupWarnings}, "warning"); ASSERT(lines.back().rfind("** WARNING: warning") != std::string::npos); - LOGV2_OPTIONS({static_cast<LogTag::Value>(LogTag::kStartupWarnings | LogTag::kPlainShell)}, + LOGV2_OPTIONS(20067, + {static_cast<LogTag::Value>(LogTag::kStartupWarnings | LogTag::kPlainShell)}, "warning"); ASSERT(lines.back().rfind("** WARNING: warning") != std::string::npos); TypeWithBSON t(1.0, 2.0); - LOGV2("{} custom formatting", "name"_attr = t); + LOGV2(20034, "{} custom formatting", "name"_attr = t); ASSERT(lines.back().rfind(t.toString() + " custom formatting") != std::string::npos); - LOGV2("{} bson", "name"_attr = t.toBSON()); + LOGV2(20035, "{} bson", "name"_attr = t.toBSON()); ASSERT(lines.back().rfind(t.toBSON().jsonString(JsonStringFormat::ExtendedRelaxedV2_0_0) + " bson") != std::string::npos); TypeWithoutBSON t2(1.0, 2.0); - LOGV2("{} custom formatting, no bson", "name"_attr = t2); + LOGV2(20036, "{} custom formatting, no bson", "name"_attr = t2); ASSERT(lines.back().rfind(t.toString() + " custom formatting, no bson") != std::string::npos); TypeWithNonMemberFormatting t3; - LOGV2("{}", "name"_attr = t3); + LOGV2(20079, "{}", "name"_attr = t3); ASSERT(lines.back().rfind(toString(t3)) != std::string::npos); } @@ -651,15 +655,15 @@ TEST_F(LogTestV2, JsonBsonFormat) { BSONObj log; - LOGV2("test"); + LOGV2(20037, "test"); auto validateRoot = [](const BSONObj& obj) { ASSERT_EQUALS(obj.getField(kTimestampFieldName).Date(), Date_t::lastNowForTest()); ASSERT_EQUALS(obj.getField(kSeverityFieldName).String(), LogSeverity::Info().toStringDataCompact()); ASSERT_EQUALS(obj.getField(kComponentFieldName).String(), LogComponent(MONGO_LOGV2_DEFAULT_COMPONENT).getNameForLog()); - ASSERT(obj.getField(kContextFieldName).String() == getThreadName()); - ASSERT(!obj.hasField(kStableIdFieldName)); + ASSERT_EQUALS(obj.getField(kContextFieldName).String(), getThreadName()); + ASSERT_EQUALS(obj.getField(kIdFieldName).Int(), 20037); ASSERT_EQUALS(obj.getField(kMessageFieldName).String(), "test"); ASSERT(!obj.hasField(kAttributesFieldName)); ASSERT(!obj.hasField(kTagsFieldName)); @@ -668,7 +672,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { validateRoot(BSONObj(linesBson.back().data())); - LOGV2("test {}", "name"_attr = 1); + LOGV2(20038, "test {}", "name"_attr = 1); auto validateAttr = [](const BSONObj& obj) { ASSERT_EQUALS(obj.getField(kMessageFieldName).String(), "test {name}"); ASSERT_EQUALS(obj.getField(kAttributesFieldName).Obj().nFields(), 1); @@ -678,7 +682,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { validateAttr(BSONObj(linesBson.back().data())); - LOGV2("test {:d}", "name"_attr = 2); + LOGV2(20039, "test {:d}", "name"_attr = 2); auto validateMsgReconstruction = [](const BSONObj& obj) { ASSERT_EQUALS(obj.getField(kMessageFieldName).String(), "test {name:d}"); ASSERT_EQUALS(obj.getField(kAttributesFieldName).Obj().nFields(), 1); @@ -687,7 +691,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { validateMsgReconstruction(mongo::fromjson(lines.back())); validateMsgReconstruction(BSONObj(linesBson.back().data())); - LOGV2("test {: <4}", "name"_attr = 2); + LOGV2(20040, "test {: <4}", "name"_attr = 2); auto validateMsgReconstruction2 = [](const BSONObj& obj) { ASSERT_EQUALS(obj.getField(kMessageFieldName).String(), "test {name: <4}"); ASSERT_EQUALS(obj.getField(kAttributesFieldName).Obj().nFields(), 1); @@ -697,7 +701,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { validateMsgReconstruction2(BSONObj(linesBson.back().data())); - LOGV2_OPTIONS({LogTag::kStartupWarnings}, "warning"); + LOGV2_OPTIONS(20068, {LogTag::kStartupWarnings}, "warning"); auto validateTags = [](const BSONObj& obj) { ASSERT_EQUALS(obj.getField(kMessageFieldName).String(), "warning"); ASSERT_EQUALS( @@ -707,7 +711,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { validateTags(mongo::fromjson(lines.back())); validateTags(BSONObj(linesBson.back().data())); - LOGV2_OPTIONS({LogComponent::kControl}, "different component"); + LOGV2_OPTIONS(20069, {LogComponent::kControl}, "different component"); auto validateComponent = [](const BSONObj& obj) { ASSERT_EQUALS(obj.getField("c"_sd).String(), LogComponent(LogComponent::kControl).getNameForLog()); @@ -718,7 +722,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { TypeWithBSON t(1.0, 2.0); - LOGV2("{} custom formatting", "name"_attr = t); + LOGV2(20041, "{} custom formatting", "name"_attr = t); auto validateCustomAttr = [&t](const BSONObj& obj) { ASSERT_EQUALS(obj.getField(kMessageFieldName).String(), "{name} custom formatting"); ASSERT_EQUALS(obj.getField(kAttributesFieldName).Obj().nFields(), 1); @@ -730,7 +734,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { validateCustomAttr(BSONObj(linesBson.back().data())); - LOGV2("{} bson", "name"_attr = t.toBSON()); + LOGV2(20042, "{} bson", "name"_attr = t.toBSON()); auto validateBsonAttr = [&t](const BSONObj& obj) { ASSERT_EQUALS(obj.getField(kMessageFieldName).String(), "{name} bson"); ASSERT_EQUALS(obj.getField(kAttributesFieldName).Obj().nFields(), 1); @@ -743,7 +747,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { TypeWithoutBSON t2(1.0, 2.0); - LOGV2("{} custom formatting", "name"_attr = t2); + LOGV2(20043, "{} custom formatting", "name"_attr = t2); auto validateCustomAttrWithoutBSON = [&t2](const BSONObj& obj) { ASSERT_EQUALS(obj.getField(kMessageFieldName).String(), "{name} custom formatting"); ASSERT_EQUALS(obj.getField(kAttributesFieldName).Obj().nFields(), 1); @@ -754,7 +758,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { validateCustomAttrWithoutBSON(BSONObj(linesBson.back().data())); TypeWithBSONSerialize t3(1.0, 2.0); - LOGV2("{}", "name"_attr = t3); + LOGV2(20044, "{}", "name"_attr = t3); auto validateCustomAttrBSONSerialize = [&t3](const BSONObj& obj) { BSONObjBuilder builder; t3.serialize(&builder); @@ -769,7 +773,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { TypeWithBothBSONFormatters t4(1.0, 2.0); - LOGV2("{}", "name"_attr = t4); + LOGV2(20045, "{}", "name"_attr = t4); auto validateCustomAttrBSONBothFormatters = [&t4](const BSONObj& obj) { BSONObjBuilder builder; t4.serialize(&builder); @@ -783,7 +787,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { validateCustomAttrBSONBothFormatters(BSONObj(linesBson.back().data())); TypeWithBSONArray t5; - LOGV2("{}", "name"_attr = t5); + LOGV2(20046, "{}", "name"_attr = t5); auto validateCustomAttrBSONArray = [&t5](const BSONObj& obj) { ASSERT_EQUALS(obj.getField(kAttributesFieldName).Obj().getField("name").type(), BSONType::Array); @@ -797,7 +801,7 @@ TEST_F(LogTestV2, JsonBsonFormat) { validateCustomAttrBSONArray(BSONObj(linesBson.back().data())); TypeWithNonMemberFormatting t6; - LOGV2("{}", "name"_attr = t6); + LOGV2(20080, "{}", "name"_attr = t6); auto validateNonMemberToBSON = [&t6](const BSONObj& obj) { ASSERT( obj.getField(kAttributesFieldName).Obj().getField("name").Obj().woCompare(toBSON(t6)) == @@ -852,7 +856,7 @@ TEST_F(LogTestV2, Containers) { // All standard sequential containers are supported std::vector<std::string> vectorStrings = {"str1", "str2", "str3"}; - LOGV2("{}", "name"_attr = vectorStrings); + LOGV2(20047, "{}", "name"_attr = vectorStrings); ASSERT_EQUALS(text.back(), text_join(vectorStrings.begin(), vectorStrings.end(), [](const std::string& str) { return str; @@ -870,7 +874,7 @@ TEST_F(LogTestV2, Containers) { // Elements can require custom formatting std::list<TypeWithBSON> listCustom = { TypeWithBSON(0.0, 1.0), TypeWithBSON(2.0, 3.0), TypeWithBSON(4.0, 5.0)}; - LOGV2("{}", "name"_attr = listCustom); + LOGV2(20048, "{}", "name"_attr = listCustom); ASSERT_EQUALS(text.back(), text_join(listCustom.begin(), listCustom.end(), [](const auto& item) { return item.toString(); @@ -890,7 +894,7 @@ TEST_F(LogTestV2, Containers) { // Optionals are also allowed as elements std::forward_list<boost::optional<bool>> listOptionalBool = {true, boost::none, false}; - LOGV2("{}", "name"_attr = listOptionalBool); + LOGV2(20049, "{}", "name"_attr = listOptionalBool); ASSERT_EQUALS(text.back(), text_join(listOptionalBool.begin(), listOptionalBool.end(), @@ -921,7 +925,7 @@ TEST_F(LogTestV2, Containers) { // Containers can be nested std::array<std::deque<int>, 4> arrayOfDeques = {{{0, 1}, {2, 3}, {4, 5}, {6, 7}}}; - LOGV2("{}", "name"_attr = arrayOfDeques); + LOGV2(20050, "{}", "name"_attr = arrayOfDeques); ASSERT_EQUALS(text.back(), text_join(arrayOfDeques.begin(), arrayOfDeques.end(), @@ -953,7 +957,7 @@ TEST_F(LogTestV2, Containers) { // Associative containers are also supported std::map<std::string, std::string> mapStrStr = {{"key1", "val1"}, {"key2", "val2"}}; - LOGV2("{}", "name"_attr = mapStrStr); + LOGV2(20051, "{}", "name"_attr = mapStrStr); ASSERT_EQUALS(text.back(), text_join(mapStrStr.begin(), mapStrStr.end(), [](const auto& item) { return fmt::format("{}: {}", item.first, item.second); })); @@ -972,7 +976,7 @@ TEST_F(LogTestV2, Containers) { {"key1", boost::optional<std::vector<int>>{{1, 2, 3}}}, {"key2", boost::optional<std::vector<int>>{boost::none}}}; - LOGV2("{}", "name"_attr = mapOptionalVector); + LOGV2(20052, "{}", "name"_attr = mapOptionalVector); ASSERT_EQUALS( text.back(), text_join(mapOptionalVector.begin(), @@ -1050,7 +1054,7 @@ TEST_F(LogTestV2, Unicode) { }; for (const auto& pair : strs) { - LOGV2("{}", "name"_attr = pair.first); + LOGV2(20053, "{}", "name"_attr = pair.first); ASSERT_EQUALS(lines.back(), pair.second); } } @@ -1082,22 +1086,22 @@ TEST_F(LogTestV2, Threads) { threads.emplace_back([&]() { for (int i = 0; i < kNumPerThread; ++i) - LOGV2("thread1"); + LOGV2(20054, "thread1"); }); threads.emplace_back([&]() { for (int i = 0; i < kNumPerThread; ++i) - LOGV2("thread2"); + LOGV2(20055, "thread2"); }); threads.emplace_back([&]() { for (int i = 0; i < kNumPerThread; ++i) - LOGV2("thread3"); + LOGV2(20056, "thread3"); }); threads.emplace_back([&]() { for (int i = 0; i < kNumPerThread; ++i) - LOGV2("thread4"); + LOGV2(20057, "thread4"); }); for (auto&& thread : threads) { @@ -1133,9 +1137,9 @@ TEST_F(LogTestV2, Ramlog) { }); }; - LOGV2("test"); + LOGV2(20058, "test"); ASSERT(verifyRamLog()); - LOGV2("test2"); + LOGV2(20059, "test2"); ASSERT(verifyRamLog()); } @@ -1166,11 +1170,11 @@ TEST_F(LogTestV2, MultipleDomains) { other_sink->set_formatter(PlainFormatter()); attach(other_sink); - LOGV2_OPTIONS({&other_domain}, "test"); + LOGV2_OPTIONS(20070, {&other_domain}, "test"); ASSERT(global_lines.empty()); ASSERT(other_lines.back() == "test"); - LOGV2("global domain log"); + LOGV2(20060, "global domain log"); ASSERT(global_lines.back() == "global domain log"); ASSERT(other_lines.back() == "test"); } @@ -1213,10 +1217,10 @@ TEST_F(LogTestV2, FileLogging) { return lines; }; - LOGV2("test"); + LOGV2(20061, "test"); ASSERT(readFile(file_name).back() == "test"); - LOGV2("test2"); + LOGV2(20062, "test2"); ASSERT(readFile(file_name).back() == "test2"); auto before_rotation = readFile(file_name); diff --git a/src/mongo/logv2/logv2_bm.cpp b/src/mongo/logv2/logv2_bm.cpp index a2726a0cf88..db09d3026da 100644 --- a/src/mongo/logv2/logv2_bm.cpp +++ b/src/mongo/logv2/logv2_bm.cpp @@ -177,7 +177,7 @@ void BM_NoopLogV2(benchmark::State& state) { ScopedLogV2Bench init(state); for (auto _ : state) - LOGV2_DEBUG(1, "noop log"); + LOGV2_DEBUG(20074, 1, "noop log"); } void BM_NoopLogArg(benchmark::State& state) { @@ -191,7 +191,7 @@ void BM_NoopLogV2Arg(benchmark::State& state) { ScopedLogV2Bench init(state); for (auto _ : state) - LOGV2_DEBUG(1, "noop log {}", "str"_attr = createLongString()); + LOGV2_DEBUG(20075, 1, "noop log {}", "str"_attr = createLongString()); } void BM_EnabledLog(benchmark::State& state) { @@ -206,7 +206,7 @@ void BM_EnabledLogV2(benchmark::State& state) { ScopedLogV2Bench init(state); for (auto _ : state) - LOGV2("enabled log"); + LOGV2(20071, "enabled log"); } void BM_EnabledLogExpensiveArg(benchmark::State& state) { @@ -221,7 +221,7 @@ void BM_EnabledLogV2ExpensiveArg(benchmark::State& state) { ScopedLogV2Bench init(state); for (auto _ : state) - LOGV2("enabled log {}", "str"_attr = createLongString()); + LOGV2(20072, "enabled log {}", "str"_attr = createLongString()); } void BM_EnabledLogManySmallArg(benchmark::State& state) { @@ -238,7 +238,8 @@ void BM_EnabledLogV2ManySmallArg(benchmark::State& state) { ScopedLogV2Bench init(state); for (auto _ : state) { - LOGV2("enabled log {}{}{}{}{}{}{}{}{}{}", + LOGV2(20073, + "enabled log {}{}{}{}{}{}{}{}{}{}", "1"_attr = 1, "2"_attr = 2, "3"_attr = "3", |