Skip to content

Commit ee82240

Browse files
authored
Report full message in JSON when using STLOG (merge from main #19362) (#19479)
2 parents 9cf6da3 + 5ac65f7 commit ee82240

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ydb/core/util/stlog.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ namespace NKikimr::NStLog {
324324
Json.WriteKey("line");
325325
Json.Write(Self->Line);
326326
}
327+
Json.WriteKey("brief_message");
328+
Json.Write(Stream.Str());
329+
Self->WriteParamsToStream(Stream);
330+
Stream << " Marker# " << Self->Marker;
327331
Json.WriteKey("message");
328332
Json.Write(Stream.Str());
329333
Self->WriteParamsToJson(Json);

ydb/core/util/stlog_ut.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@ Y_UNIT_TEST_SUITE(StLog) {
2525
(Param5, TString("abcdef")), (Param6, x1), (Param7, x2), (Param8, x3), (Param9, y1),
2626
(Param10, y2), (Param11, y3), (Param12, true), (Param13, v), (Param14, status), (Param15, id),
2727
(Param16, &s));
28-
UNIT_ASSERT_VALUES_EQUAL(stream.Str(), "{MARKER1@stlog_ut.cpp:27} hello, world Param1# 1 Param2# c Param3# 1.1 "
28+
TString message = "hello, world Param1# 1 Param2# c Param3# 1.1 "
2929
"Param4# abcdef Param5# abcdef Param6# 1 Param7# 2 Param8# 3 Param9# <null> Param10# <null> Param11# <null> "
3030
"Param12# true Param13# [1 2 3] Param14# RACE Param15# {RawX1: 1 RawX2: 288230376185266176 "
31-
"RawX3: 216172807883587664 } Param16# yep");
31+
"RawX3: 216172807883587664 } Param16# yep";
32+
UNIT_ASSERT_VALUES_EQUAL(stream.Str(), "{MARKER1@stlog_ut.cpp:27} " + message);
3233
NKikimr::NStLog::OutputLogJson = true;
3334
STLOG_STREAM(stream2, MARKER2, "hello, world", (Param1, 1), (Param2, 'c'), (Param3, 1.1f), (Param4, "abcdef"),
3435
(Param5, TString("abcdef")), (Param6, x1), (Param7, x2), (Param8, x3), (Param9, y1),
3536
(Param10, y2), (Param11, y3), (Param12, true), (Param13, v), (Param14, status), (Param15, id),
3637
(Param16, &s));
37-
UNIT_ASSERT_VALUES_EQUAL(stream2.Str(), R"({"marker":"MARKER2","file":"stlog_ut.cpp","line":36,"message":"hello, world",)"
38+
UNIT_ASSERT_VALUES_EQUAL(stream2.Str(), R"({"marker":"MARKER2","file":"stlog_ut.cpp","line":37,)"
39+
R"("brief_message":"hello, world","message":")" + message + R"( Marker# MARKER2",)"
3840
R"("Param1":1,"Param2":99,"Param3":1.1,"Param4":"abcdef","Param5":"abcdef","Param6":1,"Param7":2,"Param8":3,)"
3941
R"("Param9":null,"Param10":null,"Param11":null,"Param12":true,"Param13":[1,2,3],"Param14":"RACE","Param15":)"
4042
R"({"RawX1":"1","RawX2":"288230376185266176","RawX3":"216172807883587664"},"Param16":"yep"})");

0 commit comments

Comments
 (0)