Some docs

This commit is contained in:
2023-10-28 23:46:47 +02:00
parent 2f0b59a032
commit ecd8b3b0c9
6 changed files with 46 additions and 7 deletions

View File

@@ -93,7 +93,7 @@ public abstract class CLIApplication {
} finally {
Log.info("Bye bye.");
CLILogger.ShutdownHookDelayerLogManager.resetFinally();
CLILogger.actuallyResetLogManager();
if (!Thread.currentThread().equals(shutdownThread))
System.exit(0);
}

View File

@@ -1,6 +1,7 @@
package fr.pandacube.lib.cli.log;
import fr.pandacube.lib.cli.CLI;
import fr.pandacube.lib.cli.CLIApplication;
import fr.pandacube.lib.util.log.Log;
import fr.pandacube.lib.util.ThrowableUtil;
import fr.pandacube.lib.util.log.DailyLogRotateFileHandler;
@@ -28,12 +29,21 @@ public class CLILogger {
private static Logger logger = null;
public static class ShutdownHookDelayerLogManager extends LogManager {
private static class ShutdownHookDelayerLogManager extends LogManager {
static ShutdownHookDelayerLogManager instance;
public ShutdownHookDelayerLogManager() { instance = this; }
@Override public void reset() { /* don't reset yet. */ }
private void reset0() { super.reset(); }
public static void resetFinally() { instance.reset0(); }
private void actuallyReset() { super.reset(); }
}
/**
* Tells the LogManager to actually reset.
*
* This method is called by the shutdown hook of {@link CLIApplication}, because the {@link CLILogger} uses a custom
* {@link LogManager} that bypass the reset process during the shutdown of the process.
*/
public static void actuallyResetLogManager() {
ShutdownHookDelayerLogManager.instance.actuallyReset();
}