From 11a44f2b26d0490664eafd8bec456bca132e8dcd Mon Sep 17 00:00:00 2001 From: ermolovd Date: Sat, 2 Nov 2024 14:21:19 +0300 Subject: YT-23262: send all logs to file commit_hash:af0cfccef62a612208772fef9f0778b48ab16fda --- yt/cpp/mapreduce/client/init.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'yt/cpp/mapreduce/client/init.cpp') diff --git a/yt/cpp/mapreduce/client/init.cpp b/yt/cpp/mapreduce/client/init.cpp index e55fc51388a..44d685d779e 100644 --- a/yt/cpp/mapreduce/client/init.cpp +++ b/yt/cpp/mapreduce/client/init.cpp @@ -17,6 +17,9 @@ #include #include +#include +#include + #include #include @@ -148,6 +151,21 @@ static void ElevateInitStatus(const EInitStatus newStatus) { NDetail::GetInitStatus() = Max(NDetail::GetInitStatus(), newStatus); } +NLogging::ELogLevel ToCoreLogLevel(ILogger::ELevel level) +{ + switch (level) { + case ILogger::FATAL: + return NLogging::ELogLevel::Fatal; + case ILogger::ERROR: + return NLogging::ELogLevel::Error; + case ILogger::INFO: + return NLogging::ELogLevel::Info; + case ILogger::DEBUG: + return NLogging::ELogLevel::Debug; + } + Y_ABORT(); +} + void CommonInitialize(int argc, const char** argv) { auto logLevelStr = to_lower(TConfig::Get()->LogLevel); @@ -159,7 +177,15 @@ void CommonInitialize(int argc, const char** argv) } auto logPath = TConfig::Get()->LogPath; - auto logger = logPath.empty() ? CreateStdErrLogger(logLevel) : CreateFileLogger(logLevel, logPath); + ILoggerPtr logger; + if (logPath.empty()) { + logger = CreateStdErrLogger(logLevel); + } else { + logger = CreateFileLogger(logLevel, logPath); + + auto coreLoggingConfig = NLogging::TLogManagerConfig::CreateLogFile(logPath, ToCoreLogLevel(logLevel)); + NLogging::TLogManager::Get()->Configure(coreLoggingConfig); + } SetLogger(logger); TProcessState::Get()->SetCommandLine(argc, argv); -- cgit v1.3