mirror of
https://github.com/System-End/Discord-MC-Chat.git
synced 2026-04-19 22:05:11 +00:00
Separate Logger cleanup in shutdown hook for standalone environment
This commit is contained in:
parent
ce3edaa7db
commit
3959291cd2
2 changed files with 9 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package com.xujiayao.discord_mc_chat.standalone;
|
||||
|
||||
import com.xujiayao.discord_mc_chat.DMCC;
|
||||
import com.xujiayao.discord_mc_chat.utils.logging.impl.LoggerImpl;
|
||||
|
||||
/**
|
||||
* The entry point for Standalone environment.
|
||||
|
|
@ -16,7 +17,12 @@ public class StandaloneDMCC {
|
|||
*/
|
||||
public static void main(String[] args) {
|
||||
// Register shutdown hook for standalone mode
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(DMCC::shutdown, "DMCC-ShutdownHook"));
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
DMCC.shutdown();
|
||||
|
||||
// Logger cleanup
|
||||
LoggerImpl.shutdown();
|
||||
}, "DMCC-ShutdownHook"));
|
||||
|
||||
// Initialize DMCC, block until initialization is complete
|
||||
if (DMCC.init()) {
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ public class LoggerImpl implements Logger {
|
|||
|
||||
/**
|
||||
* Closes the file writer if it was initialized and uninstalls AnsiConsole.
|
||||
* <p>
|
||||
* Only Standalone environment requires this cleanup.
|
||||
*/
|
||||
public static void shutdown() {
|
||||
if (fileWriter != null) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue