All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.narayana.jta.runtime.graal.DisableLoggingFeature Maven / Gradle / Ivy

There is a newer version: 3.17.0
Show newest version
package io.quarkus.narayana.jta.runtime.graal;

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

import org.graalvm.nativeimage.hosted.Feature;

/**
 * Disables logging during the analysis phase
 */
public class DisableLoggingFeature implements Feature {

    private static final String[] CATEGORIES = {
            "com.arjuna.ats.arjuna"
    };

    private final Map 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.SEVERE);
        }
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy