-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25936 from gastaldi/disable_websocket_logging
Disable Websockets logging during native image build
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...runtime/src/main/java/io/quarkus/websockets/client/runtime/DisableLoggingAutoFeature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |