mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Fix plugin loggers on shutdown (#5592)
Potentially this should be merged back into the original logging changes patches
This commit is contained in:
parent
2da891fcfa
commit
a76998d235
1 changed files with 67 additions and 0 deletions
|
@ -0,0 +1,67 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Jos=C3=A9=20Miguel=20Moreno?= <josemmo@pm.me>
|
||||||
|
Date: Sat, 5 Jun 2021 13:45:15 +0200
|
||||||
|
Subject: [PATCH] Fix plugin loggers on server shutdown
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/log/CustomLogManager.java b/src/main/java/io/papermc/paper/log/CustomLogManager.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..c1d3bac79bb8b4796c013ff4472f75dcd79602dc
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/log/CustomLogManager.java
|
||||||
|
@@ -0,0 +1,26 @@
|
||||||
|
+package io.papermc.paper.log;
|
||||||
|
+
|
||||||
|
+import java.util.logging.LogManager;
|
||||||
|
+
|
||||||
|
+public class CustomLogManager extends LogManager {
|
||||||
|
+ private static CustomLogManager instance;
|
||||||
|
+
|
||||||
|
+ public CustomLogManager() {
|
||||||
|
+ instance = this;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public void reset() {
|
||||||
|
+ // Ignore calls to this method
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void superReset() {
|
||||||
|
+ super.reset();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void forceReset() {
|
||||||
|
+ if (instance != null) {
|
||||||
|
+ instance.superReset();
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
index dd9ab51e904be2f2f2a2981d4f0f6638a6895e8d..d2161a3c3b9a2b2d463ac778656c95167c10a49d 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
|
@@ -1025,6 +1025,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
net.minecrell.terminalconsole.TerminalConsoleAppender.close(); // Paper - Use TerminalConsoleAppender
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
+ io.papermc.paper.log.CustomLogManager.forceReset(); // Paper - Reset loggers after shutdown
|
||||||
|
this.onServerExit();
|
||||||
|
// Paper end
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
index 5b48047242e20c216b110502935763ea433c55cd..56a784e943cb5d8b15b41e3e66545ebf166c221c 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
@@ -20,6 +20,12 @@ public class Main {
|
||||||
|
public static boolean useJline = true;
|
||||||
|
public static boolean useConsole = true;
|
||||||
|
|
||||||
|
+ // Paper start - Hijack log manager to ensure logging on shutdown
|
||||||
|
+ static {
|
||||||
|
+ System.setProperty("java.util.logging.manager", "io.papermc.paper.log.CustomLogManager");
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// Paper start
|
||||||
|
final String warnWhenLegacyFormattingDetected = String.join(".", "net", "kyori", "adventure", "text", "warnWhenLegacyFormattingDetected");
|
Loading…
Reference in a new issue