-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[core] Add ROOT_LOG env var support for RLogger #21455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
deveshbervar
wants to merge
6
commits into
root-project:master
Choose a base branch
from
deveshbervar:feature/rlogger-env-var
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+200
−17
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7015327
[core] Add ROOT_LOG env var support for RLogger
deveshbervar 8f759ed
[core] Add test for ROOT_LOG env var in RLogger
deveshbervar b81d9d3
[core] Restore accidentally removed comments in Emit
deveshbervar eebf610
[core] Address reviewer feedback on RLogger env var
deveshbervar 40d8a5f
[core] Add test for explicit verbosity over ROOT_LOG env var
deveshbervar 35592c2
[core] Fix clang-format and string_view conversion issues
deveshbervar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Test that ROOT_LOG env var correctly configures RLogger channel verbosity. | ||
silverweed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // ROOT_LOG is parsed once at RLogManager construction (process startup), | ||
| // so each test case is a separate executable launched with the env var set. | ||
|
|
||
| #include "ROOT/RLogger.hxx" | ||
| #include "gtest/gtest.h" | ||
|
|
||
| // Declare a test channel the same way ROOT modules do | ||
| ROOT::RLogChannel &TestChannel() | ||
| { | ||
| static ROOT::RLogChannel channel("ROOT.TestChannel"); | ||
| return channel; | ||
| } | ||
|
|
||
| // Test: channel verbosity set via ROOT_LOG is reflected in GetEnvVerbosity | ||
| TEST(RLoggerEnvVar, EnvVerbosityIsStored) | ||
| { | ||
| // ROOT_LOG was set to 'ROOT.TestChannel=Error' before process start | ||
| // (set in CMakeLists via set_tests_properties) | ||
| auto level = ROOT::RLogManager::Get().GetEnvVerbosity("ROOT.TestChannel"); | ||
| EXPECT_EQ(level, ROOT::ELogLevel::kError); | ||
| } | ||
|
|
||
| // Test: unknown channel returns kUnset | ||
| TEST(RLoggerEnvVar, UnknownChannelReturnsUnset) | ||
| { | ||
| auto level = ROOT::RLogManager::Get().GetEnvVerbosity("ROOT.DoesNotExist"); | ||
| EXPECT_EQ(level, ROOT::ELogLevel::kUnset); | ||
| } | ||
|
|
||
| // Test: channel effective verbosity uses env var when channel has no explicit level | ||
| TEST(RLoggerEnvVar, EffectiveVerbosityUsesEnvVar) | ||
| { | ||
| // Channel has no explicit verbosity set, so should use env var value | ||
| auto effective = TestChannel().GetEffectiveVerbosity(ROOT::RLogManager::Get()); | ||
| EXPECT_EQ(effective, ROOT::ELogLevel::kError); | ||
| } | ||
| // Test: explicitly set verbosity on a channel takes precedence over ROOT_LOG env var. | ||
| // ROOT_LOG sets ROOT.TestChannel=Error, but we explicitly set it to kInfo here. | ||
| // The explicit setting should win. | ||
| TEST(RLoggerEnvVar, ExplicitVerbosityTakesPrecedenceOverEnvVar) | ||
| { | ||
| // ROOT_LOG set ROOT.TestChannel=Error via environment | ||
| // Now explicitly override it to kInfo | ||
| TestChannel().SetVerbosity(ROOT::ELogLevel::kInfo); | ||
|
|
||
| // Explicit verbosity should win over env var | ||
| EXPECT_EQ(TestChannel().GetEffectiveVerbosity(ROOT::RLogManager::Get()), ROOT::ELogLevel::kInfo); | ||
|
|
||
| // Reset back to kUnset so other tests are not affected | ||
| TestChannel().SetVerbosity(ROOT::ELogLevel::kUnset); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.