blob: ab5a4f2626fcdec420ab6f48f53c6060368949d8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
|