Skip to content

Commit a847c75

Browse files
author
hiddenpath
committed
YT-23645: Introduce IsDefaultConfigured method in yt/core logger
commit_hash:8e8156e1330120223f9e7a5b850380a7c75a7929
1 parent 616eb98 commit a847c75

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

yt/yt/core/logging/log_manager.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ class TLogManager::TImpl
392392

393393
if (!IsConfiguredFromEnv()) {
394394
DoUpdateConfig(TLogManagerConfig::CreateDefault(), /*fromEnv*/ false);
395+
DefaultConfigured_.store(true);
395396
}
396397

397398
SystemCategory_ = GetCategory(SystemLoggingCategoryName);
@@ -428,6 +429,13 @@ class TLogManager::TImpl
428429
if (sync) {
429430
future.Get().ThrowOnError();
430431
}
432+
433+
DefaultConfigured_.store(false);
434+
}
435+
436+
bool IsDefaultConfigured()
437+
{
438+
return DefaultConfigured_.load();
431439
}
432440

433441
void ConfigureFromEnv()
@@ -1435,6 +1443,7 @@ class TLogManager::TImpl
14351443
// Incrementing version forces loggers to update their own default configuration (default level etc.).
14361444
std::atomic<int> Version_ = 0;
14371445

1446+
std::atomic<bool> DefaultConfigured_ = false;
14381447
std::atomic<bool> ConfiguredFromEnv_ = false;
14391448

14401449
// These are just cached (for performance reason) copies from Config_.
@@ -1544,6 +1553,14 @@ void TLogManager::Configure(TLogManagerConfigPtr config, bool sync)
15441553
Impl_->Configure(std::move(config), /*fromEnv*/ false, sync);
15451554
}
15461555

1556+
bool TLogManager::IsDefaultConfigured()
1557+
{
1558+
[[unlikely]] if (!Impl_->IsInitialized()) {
1559+
return false;
1560+
}
1561+
return Impl_->IsDefaultConfigured();
1562+
}
1563+
15471564
void TLogManager::ConfigureFromEnv()
15481565
{
15491566
[[unlikely]] if (!Impl_->IsInitialized()) {

yt/yt/core/logging/log_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class TLogManager
3232
static TLogManager* Get();
3333

3434
void Configure(TLogManagerConfigPtr config, bool sync = true);
35+
bool IsDefaultConfigured();
3536

3637
void ConfigureFromEnv();
3738
bool IsConfiguredFromEnv();

0 commit comments

Comments
 (0)