Skip to content

Commit

Permalink
Merge pull request #25936 from gastaldi/disable_websocket_logging
Browse files Browse the repository at this point in the history
Disable Websockets logging during native image build
  • Loading branch information
gastaldi authored Jun 3, 2022
2 parents 15677f0 + 435fb77 commit 338fe10
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.quarkus.websockets.client.runtime;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.graalvm.nativeimage.hosted.Feature;

import com.oracle.svm.core.annotate.AutomaticFeature;

/**
* Disables logging during the analysis phase
*/
@AutomaticFeature
public class DisableLoggingAutoFeature implements Feature {

private static final String[] CATEGORIES = {
"io.undertow.websockets",
};

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

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

@Override
public void afterAnalysis(AfterAnalysisAccess access) {
for (String category : CATEGORIES) {
Level level = categoryMap.remove(category);
if (level != null) {
Logger logger = Logger.getLogger(category);
logger.setLevel(level);
}
}
}
}

0 comments on commit 338fe10

Please sign in to comment.