Skip to content

Commit

Permalink
Hide DnsServerAddressStreamProviders Messages During Native Build
Browse files Browse the repository at this point in the history
When building a native executable on macOS, the following message is printed during analysis:

[11:59:56,705 WARN  [io.net.res.dns.DnsServerAddressStreamProviders] Cannot find io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider in the classpath, falling back to system defaults. This may result in incorrect DNS resolutions on macOS. Check whether you have a dependency on 'io.netty:netty-resolver-dns-native-macos'

This commit suppresses this unnecessary message by modifying the DisableLoggingFeature to set the logger level for this message to SEVERE.
  • Loading branch information
cescoffier committed Oct 18, 2024
1 parent a4b05f7 commit be318b5
Showing 1 changed file with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,47 @@
*/
public class DisableLoggingFeature implements Feature {

private static final String[] CATEGORIES = {
"org.jboss.threads"
/**
* Category to configure to WARNING
*/
private static final String[] WARN_CATEGORIES = {
"org.jboss.threads" };

/**
* Category to configure to ERROR
*/
private static final String[] ERROR_CATEGORIES = {
"io.netty.resolver.dns.DnsServerAddressStreamProviders"
};

private final Map<String, Level> categoryMap = new HashMap<>(CATEGORIES.length);
private final Map<String, Level> categoryMap = new HashMap<>(WARN_CATEGORIES.length + ERROR_CATEGORIES.length);

@Override
public void beforeAnalysis(BeforeAnalysisAccess access) {
for (String category : CATEGORIES) {
for (String category : WARN_CATEGORIES) {
Logger logger = Logger.getLogger(category);
categoryMap.put(category, logger.getLevel());
logger.setLevel(Level.WARNING);
}

for (String category : ERROR_CATEGORIES) {
Logger logger = Logger.getLogger(category);
categoryMap.put(category, logger.getLevel());
logger.setLevel(Level.SEVERE);
}
}

@Override
public void afterAnalysis(AfterAnalysisAccess access) {
for (String category : CATEGORIES) {
Level level = categoryMap.remove(category);
Logger logger = Logger.getLogger(category);
logger.setLevel(level);
for (Map.Entry<String, Level> entry : categoryMap.entrySet()) {
Logger logger = Logger.getLogger(entry.getKey());
logger.setLevel(entry.getValue());
}
categoryMap.clear();
}

@Override
public String getDescription() {
return "Disables INFO logging during the analysis phase";
return "Adapts logging during the analysis phase";
}
}

0 comments on commit be318b5

Please sign in to comment.