aboutsummaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/interface/logging/yt_log.cpp
diff options
context:
space:
mode:
authorermolovd <ermolovd@yandex-team.com>2024-11-28 15:34:32 +0300
committerermolovd <ermolovd@yandex-team.com>2024-11-28 15:45:53 +0300
commit667d7a8073070f148e1adc7650b55e7a7ef33439 (patch)
treee03282783ef7606d02176e91114582bbc8f5dd13 /yt/cpp/mapreduce/interface/logging/yt_log.cpp
parent4ba1f3d99a3e5499a3a0fa5c22a4628fe41f06f4 (diff)
downloadydb-667d7a8073070f148e1adc7650b55e7a7ef33439.tar.gz
YT-23645: mapreduce client can use yt/core log manager
commit_hash:7007a3c7f56a6f271073811160f00f03162aaaa6
Diffstat (limited to 'yt/cpp/mapreduce/interface/logging/yt_log.cpp')
-rw-r--r--yt/cpp/mapreduce/interface/logging/yt_log.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/yt/cpp/mapreduce/interface/logging/yt_log.cpp b/yt/cpp/mapreduce/interface/logging/yt_log.cpp
index d41bfa559f..6c464d48ac 100644
--- a/yt/cpp/mapreduce/interface/logging/yt_log.cpp
+++ b/yt/cpp/mapreduce/interface/logging/yt_log.cpp
@@ -26,23 +26,34 @@ public:
::TSourceLocation sourceLocation,
TStringBuf anchorMessage) override
{
+ if (auto* defaultLogManager = GetDefaultLogManager()) {
+ defaultLogManager->RegisterStaticAnchor(anchor, sourceLocation, anchorMessage);
+ }
auto guard = Guard(Mutex_);
anchor->SourceLocation = sourceLocation;
anchor->AnchorMessage = anchorMessage;
}
- void UpdateAnchor(TLoggingAnchor* /*position*/) override
- { }
+ void UpdateAnchor(TLoggingAnchor* anchor) override
+ {
+ if (auto* defaultLogManager = GetDefaultLogManager()) {
+ defaultLogManager->UpdateAnchor(anchor);
+ }
+ }
void Enqueue(TLogEvent&& event) override
{
- auto message = TString(event.MessageRef.ToStringBuf());
- LogMessage(
- ToImplLevel(event.Level),
- ::TSourceLocation(event.SourceFile, event.SourceLine),
- "%.*s",
- event.MessageRef.size(),
- event.MessageRef.begin());
+ if (auto logger = GetLogger()) {
+ LogMessage(
+ logger,
+ ToImplLevel(event.Level),
+ ::TSourceLocation(event.SourceFile, event.SourceLine),
+ "%.*s",
+ event.MessageRef.size(),
+ event.MessageRef.begin());
+ } else if (auto* defaultLogManager = GetDefaultLogManager()) {
+ defaultLogManager->Enqueue(std::move(event));
+ }
}
const TLoggingCategory* GetCategory(TStringBuf categoryName) override
@@ -81,7 +92,7 @@ private:
}
}
- static void LogMessage(ILogger::ELevel level, const ::TSourceLocation& sourceLocation, const char* format, ...)
+ static void LogMessage(const ILoggerPtr& logger, ILogger::ELevel level, const ::TSourceLocation& sourceLocation, const char* format, ...)
{
va_list args;
va_start(args, format);