-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Respect custom ConfigRoot.name in ConfigInstantiator & fix minLogLevel handling #24432
Conversation
@@ -60,7 +61,16 @@ public static void handleObject(Object o) { | |||
} | |||
|
|||
final Class<?> cls = o.getClass(); | |||
final String name = dashify(cls.getSimpleName().substring(0, cls.getSimpleName().length() - clsNameSuffix.length())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this change, the following didn't apply the actual config:
quarkus/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java
Lines 73 to 74 in 2b44967
LogBuildTimeConfig buildConfig = new LogBuildTimeConfig(); | |
ConfigInstantiator.handleObject(buildConfig); |
because
quarkus.log-build-time.min-level
was looked up, which obviously doesn't exist.
if (configRoot != null && !configRoot.name().equals(ConfigItem.HYPHENATED_ELEMENT_NAME)) { | ||
name = configRoot.name(); | ||
if (name.startsWith("<<")) { | ||
throw new IllegalArgumentException("Found unsupported @ConfigRoot.name = " + name + " on " + cls); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a quick look at other default names and didn't see how to support them properly. So better complain loudly here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case do we have a root that is not in the hyphenated format? (I think it makes sense to protect that case, just wondering).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a few that are using @ConfigRoot.name = ConfigItem.PARENT
, e.g. CommandLineRuntimeConfig
.
But those are very special and it doesn't make sense to pass them to ConfigInstantiator
, AFAICS.
final Level logLevel = getLogLevel(categoryName, config, categories, buildConfig.minLevel); | ||
final Level minLogLevel = buildCategory == null | ||
? buildConfig.minLevel | ||
: buildCategory.minLevel.getLevel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that logBuildTimeConfig
is loaded properly, buildCategory.minLevel.getLevel()
would fail due to:
quarkus/core/runtime/src/main/java/io/quarkus/runtime/logging/InheritableLevel.java
Line 77 in 2cbd177
throw new NoSuchElementException(); |
(in case the min-level is not set directly for the given category)
So, I had to use the same inheritance-aware approach as for the actual log level (and/or the min-level in LoggingResourceProcessor):
return rootMinLevel; | ||
} | ||
categoryName = categoryName.substring(0, lastDotIndex); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've rewritten the alorithm that goes up the category path to:
- use it for different
Config
objects (hence thelevelExtractor
) - fix a gap in the original implementation that was falling back to the root (min-)level too early (e.g. if
com.foo.bar
has.level
but nomin-level
, then we must continue withcom
in casecom.foo
is not configured)
/cc @galderz
core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java
Outdated
Show resolved
Hide resolved
@stuartwdouglas in context of this, it's unclear to me how that's supposed to work: quarkus/core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestHandler.java Line 28 in 614b831
given that BannerRuntimeConfig does not define a name for @ConfigRoot and AFAICS, there is no banner-runtime infix.
|
This comment has been minimized.
This comment has been minimized.
Thanks @radcortez! |
Reported via #24406 (but it's not the main issue)
I'll add some notes to the changed code...