Skip to content
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

Merged
merged 1 commit into from
Mar 22, 2022
Merged

Respect custom ConfigRoot.name in ConfigInstantiator & fix minLogLevel handling #24432

merged 1 commit into from
Mar 22, 2022

Conversation

famod
Copy link
Member

@famod famod commented Mar 20, 2022

Reported via #24406 (but it's not the main issue)

I'll add some notes to the changed code...

@@ -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()));
Copy link
Member Author

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:

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);
Copy link
Member Author

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.

Copy link
Member

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).

Copy link
Member Author

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();
Copy link
Member Author

@famod famod Mar 20, 2022

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:


(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);
}
Copy link
Member Author

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 the levelExtractor)
  • 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 no min-level, then we must continue with com in case com.foo is not configured)

/cc @galderz

@famod
Copy link
Member Author

famod commented Mar 20, 2022

@stuartwdouglas in context of this, it's unclear to me how that's supposed to work:

ConfigInstantiator.handleObject(bannerRuntimeConfig);

given that BannerRuntimeConfig does not define a name for @ConfigRoot and AFAICS, there is no banner-runtime infix.

@quarkus-bot

This comment has been minimized.

@gsmet gsmet requested a review from radcortez March 21, 2022 08:37
@famod
Copy link
Member Author

famod commented Mar 21, 2022

Thanks @radcortez!
Anyone else? @stuartwdouglas, @geoand?

@famod famod requested a review from geoand March 22, 2022 13:33
@famod famod added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Mar 22, 2022
@famod famod merged commit 02d5ca6 into quarkusio:main Mar 22, 2022
@famod famod deleted the ConfigInstantiator-root-name branch March 22, 2022 17:08
@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Mar 22, 2022
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Mar 22, 2022
@gsmet gsmet modified the milestones: 2.8.0.CR1, 2.7.6.Final May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants