Browse Source

YT-21868: Fix missing anchor for single messages in YT_LOG_XXX macros
438bc5ed4e35d7a3aeffcce25e862d21289d4cad

arkady-e1ppa 9 months ago
parent
commit
f89ac54b9e
1 changed files with 14 additions and 1 deletions
  1. 14 1
      library/cpp/yt/logging/logger-inl.h

+ 14 - 1
library/cpp/yt/logging/logger-inl.h

@@ -213,7 +213,20 @@ TLogMessage BuildLogMessage(
         AppendMessageTags(&builder, loggingContext, logger);
         builder.AppendChar(')');
     }
-    return {builder.Flush(), TStringBuf()};
+
+    if constexpr (std::same_as<TStringBuf, std::remove_cvref_t<T>>) {
+        // NB(arkady-e1ppa): This is the overload where TStringBuf
+        // falls as well as zero-argument format strings.
+        // Formerly (before static analysis) there was a special overload
+        // which guaranteed that Anchor is set to the value of said TStringBuf
+        // object. Now we have overload for TFormatString<> which fordids
+        // us having overload for TStringBuf (both have implicit ctors from
+        // string literals) thus we have to accommodate TStringBuf specifics
+        // in this if constexpr part.
+        return {builder.Flush(), obj};
+    } else {
+        return {builder.Flush(), TStringBuf()};
+    }
 }
 
 inline TLogMessage BuildLogMessage(