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

org.yamcs.logging.YamcsLogManager Maven / Gradle / Ivy

There is a newer version: 5.10.9
Show newest version
package org.yamcs.logging;

import java.io.IOException;
import java.io.InputStream;
import java.util.logging.LogManager;

/**
 * Customized version of {@link LogManager} so that we can keep logging from within shutdown hooks.
 * 

* This LogManager must be activated early via a JVM property java.util.logging.manager */ public class YamcsLogManager extends LogManager { /** * Does nothing. */ @Override public void reset() { // This gets called via a shutdown hook. // Override to do nothing by default. } private void internalReset() { super.reset(); } public static LogManager setup(InputStream inputStream) throws IOException { LogManager logManager = getLogManager(); if (logManager instanceof YamcsLogManager) { ((YamcsLogManager) logManager).internalReset(); } logManager.readConfiguration(inputStream); return logManager; } /** * Reset the logging configuration */ public static void shutdown() { LogManager logManager = getLogManager(); if (logManager instanceof YamcsLogManager) { // Not the case in unit tests ((YamcsLogManager) logManager).internalReset(); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy