[core] Add ROOT_LOG env var support for RLogger#21455
[core] Add ROOT_LOG env var support for RLogger#21455deveshbervar wants to merge 8 commits intoroot-project:masterfrom
Conversation
|
@dpiparo ping! PR ready for review. I have implemented the ROOT_LOG |
|
Is testing perhaps still missing? |
|
Hi @dpiparo, tests have been added in core/foundation/test/RLoggerEnvVar.cxx. Since RLogManager is a static singleton that parses ROOT_LOG once at Please let me know if this approach is acceptable or if you'd prefer |
| // Is there a specific level for the channel? If so, take that, | ||
| // overruling the global one. | ||
| if (channel->GetEffectiveVerbosity(*this) < entry.fLevel) | ||
| return true; | ||
|
|
||
| // Lock-protected extraction of handlers, such that they don't get added during the | ||
| // handler iteration. |
There was a problem hiding this comment.
Why are those code comments no longer relevant/helpful?
|
Hi @pcanal, |
|
Thank you @silverweed for the detailed review! I have addressed all the points:
Regarding the roottest integration test suggestion - I would appreciate |
|
Thanks for the changes. Maybe a |
|
Hi @silverweed, I Added a test case that sets the channel verbosity explicitly to kInfo |
Test Results0 tests 0 ✅ 0s ⏱️ Results for commit 35592c2. ♻️ This comment has been updated with latest results. |
|
@deveshbervar all CI builds failed in the configuration step: did you test your changes locally before updating the PR? |
|
Hi @silverweed, Sorry for not catching this before pushing. Fixed the clang-format issues and string_view conversion errors. |
| #ifdef _WIN32 | ||
| #include <cstdlib> | ||
| namespace { | ||
| int gEnvSet = _putenv("ROOT_LOG=ROOT.TestChannel=Error"); |
There was a problem hiding this comment.
Why this change? You can set the environment using the ENVIRONMENT argument for ROOT_ADD_TEST, no?
I just noticed you were using a different function to do so (and I'm not sure if that would have worked, I guess not), but I think you could just do
ROOT_ADD_TEST(RLoggerEnvVar RLoggerEnvVar.cxx ENVIRONMENT ROOT_LOG=ROOT.TestChannel=Error LIBRARIES Core)
no?
Also, you said you tested it: was it working for you locally? Did you make this change because the CI failed?
|
Thanks for the suggestion! @silverweed I checked the ROOT_ADD_GTEST macro definition and it already supports an ENVIRONMENT argument, so I've updated it to: |
|
@deveshbervar I just tried to apply your PR locally on Do you not have this error? Did you actually try to at the very least build this on your machine? |
Why
Enables per-channel verbosity to be configured at startup via an
environment variable, without recompiling ROOT. This allows tracing
(e.g. CMS autoparsing after #7609) by simply setting ROOT_LOG.
What
Setting ROOT_LOG at startup now configures RLogger channel verbosity:
export ROOT_LOG='ROOT.InterpreterPerf=Debug(3),ROOT.RBrowser=Error'
Supported levels: Fatal, Error, Warning, Info, Debug, Debug(N).
gDebug is also applied as a global verbosity floor.
Changes
RLogger.hxx: addedfEnvVerbositymap toRLogManager, addedGetEnvVerbosity(), updatedGetEffectiveVerbosity()to checkper-channel env overrides before falling back to global verbosity
RLogger.cxx: constructor now parses ROOT_LOG and applies gDebugTests
Since RLogManager is a static singleton initialized once at process
startup, setenv() mid-test does not affect it. I would appreciate
guidance from the maintainer on the recommended approach for testing
this feature. Happy to add tests based on your feedback.