@@ -106,28 +106,22 @@ void TNodeWarden::RenderWholePage(IOutputStream& out) {
106
106
TAG (TH3) { out << " StorageConfig" ; }
107
107
DIV () {
108
108
out << " <p>Self-management enabled: " << (SelfManagementEnabled ? " yes" : " no" ) << " </p>" ;
109
- TString s;
110
- NProtoBuf::TextFormat::PrintToString (StorageConfig, &s);
111
109
out << " <pre>" ;
112
- EscapeHtmlString (out, s );
110
+ OutputPrettyMessage (out, StorageConfig );
113
111
out << " </pre>" ;
114
112
}
115
113
116
114
TAG (TH3) { out << " Static service set" ; }
117
115
DIV () {
118
- TString s;
119
- NProtoBuf::TextFormat::PrintToString (StaticServices, &s);
120
116
out << " <pre>" ;
121
- EscapeHtmlString (out, s );
117
+ OutputPrettyMessage (out, StaticServices );
122
118
out << " </pre>" ;
123
119
}
124
120
125
121
TAG (TH3) { out << " Dynamic service set" ; }
126
122
DIV () {
127
- TString s;
128
- NProtoBuf::TextFormat::PrintToString (DynamicServices, &s);
129
123
out << " <pre>" ;
130
- EscapeHtmlString (out, s );
124
+ OutputPrettyMessage (out, DynamicServices );
131
125
out << " </pre>" ;
132
126
}
133
127
@@ -406,3 +400,31 @@ void NKikimr::NStorage::EscapeHtmlString(IOutputStream& out, const TString& s) {
406
400
}
407
401
dump (s.size ());
408
402
}
403
+
404
+ void NKikimr::NStorage::OutputPrettyMessage (IOutputStream& out, const NProtoBuf::Message& message) {
405
+ class TFieldPrinter : public NProtoBuf ::TextFormat::FastFieldValuePrinter {
406
+ public:
407
+ void PrintBytes (const TProtoStringType& value, NProtoBuf::TextFormat::BaseTextGenerator *generator) const override {
408
+ TStringStream newValue;
409
+ constexpr size_t maxPrintedLen = 32 ;
410
+ for (size_t i = 0 ; i < Min<size_t >(value.size (), maxPrintedLen); ++i) {
411
+ if (i) {
412
+ newValue << ' ' ;
413
+ }
414
+ newValue << Sprintf (" %02x" , static_cast <std::byte>(value[i]));
415
+ }
416
+ if (value.size () > maxPrintedLen) {
417
+ newValue << " ... (total " << value.size () << " bytes)" ;
418
+ }
419
+ TString& s = newValue.Str ();
420
+ generator->Print (s.data (), s.size ());
421
+ }
422
+ };
423
+
424
+ NProtoBuf::TextFormat::Printer p;
425
+ p.SetDefaultFieldValuePrinter (new TFieldPrinter);
426
+
427
+ TString s;
428
+ p.PrintToString (message, &s);
429
+ EscapeHtmlString (out, s);
430
+ }
0 commit comments