summaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/interface/logging/structured.cpp
diff options
context:
space:
mode:
authorAlexander Smirnov <[email protected]>2025-05-03 00:51:50 +0000
committerAlexander Smirnov <[email protected]>2025-05-03 00:51:50 +0000
commit423e33de11b68a79baf2677690525aeb2052655c (patch)
tree27d26401aab68b20d7392d9ba447e54a3716f0ed /yt/cpp/mapreduce/interface/logging/structured.cpp
parent726e4fe93a06affb8a5805f80f779e1ebc891ffc (diff)
parent0a53819a4fa41d22e878c4cd3c4d95330f583deb (diff)
Merge branch 'rightlib' into merge-libs-250503-0050
Diffstat (limited to 'yt/cpp/mapreduce/interface/logging/structured.cpp')
-rw-r--r--yt/cpp/mapreduce/interface/logging/structured.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/yt/cpp/mapreduce/interface/logging/structured.cpp b/yt/cpp/mapreduce/interface/logging/structured.cpp
new file mode 100644
index 00000000000..ab5a4f2626f
--- /dev/null
+++ b/yt/cpp/mapreduce/interface/logging/structured.cpp
@@ -0,0 +1,43 @@
+#include "structured.h"
+
+#include <yt/yt/core/logging/config.h>
+#include <yt/yt/core/logging/file_log_writer.h>
+
+#include <yt/yt/core/misc/fs.h>
+
+namespace NYT::NDetail {
+
+using namespace NLogging;
+
+////////////////////////////////////////////////////////////////////////////////
+
+void InitializeStructuredLogging(
+ TLogManagerConfigPtr logManagerConfig,
+ const TString& structuredLogPath)
+{
+ auto ruleConfig = New<TRuleConfig>();
+ ruleConfig->MinLevel = ELogLevel::Info;
+ ruleConfig->Writers.push_back(StructuredLogTypeName);
+ ruleConfig->IncludeCategories = {"Structured"};
+
+ auto writerConfig = New<TFileLogWriterConfig>();
+ writerConfig->Type = StructuredLogTypeName;
+ writerConfig->FileName = NFS::NormalizePathSeparators(structuredLogPath);
+ writerConfig->Format = ELogFormat::Json;
+
+ logManagerConfig->Rules.emplace_back(std::move(ruleConfig));
+
+ EmplaceOrCrash(
+ logManagerConfig->Writers,
+ StructuredLogTypeName,
+ ConvertTo<NYTree::IMapNodePtr>(writerConfig));
+}
+
+void RegisterStructuredLogWriterFactory()
+{
+ TLogManager::Get()->RegisterWriterFactory(StructuredLogTypeName, GetFileLogWriterFactory());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace NYT::NDetail