mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Rewrite background debug logger so now we can re-enable it.
Former-commit-id: bcbebc1af01f40ae7b40d818067f6830d5ccb711
This commit is contained in:
1 parent
eb01226b6e
commit
d6722e189c
3 files changed
+19
-39
No files matched your search
@@ -732,6 +732,15 @@ public class QuickShop extends JavaPlugin {
|
||||
}
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<String> debugLogs = Util.getDebugLogs();
|
||||
while (debugLogs.size() > 2000) {
|
||||
debugLogs.remove(debugLogs.size() - 1);
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(this, 0, 20 * 60 * 60);
|
||||
}
|
||||
|
||||
private void registerIntegrations() {
|
||||
|
||||
@@ -218,17 +218,10 @@ public class Paste {
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\tInternal Debug Log:\n");
|
||||
if (Util.isDevMode()) {
|
||||
finalReport
|
||||
.append("\t\t\n")
|
||||
.append(Util.list2String(Util.getDebugLogs()).replaceAll(",", "\n"))
|
||||
.append("\n");
|
||||
} else {
|
||||
finalReport
|
||||
.append("\t\t\n")
|
||||
.append("Disabled.")
|
||||
.append("\n");
|
||||
}
|
||||
finalReport
|
||||
.append("\t\t\n")
|
||||
.append(Util.list2String(Util.getDebugLogs()).replaceAll(",", "\n"))
|
||||
.append("\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
// try {
|
||||
// finalReport.append("\t*********************************\n");
|
||||
|
||||
@@ -52,7 +52,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.Database.MySQLCore;
|
||||
import org.maxgamer.quickshop.NonQuickShopStuffs.de.Keyle.MyPet.api.util.Colorizer;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.DisplayItem;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
@@ -75,7 +74,7 @@ public class Util {
|
||||
static short tookLongTimeCostTimes;
|
||||
|
||||
@Getter
|
||||
private static List<String> debugLogs = Collections.synchronizedList(new LinkedList<>());
|
||||
public static List<String> debugLogs = Collections.synchronizedList(new LinkedList<>());
|
||||
|
||||
private static boolean devMode = false;
|
||||
|
||||
@@ -292,6 +291,9 @@ public class Util {
|
||||
*/
|
||||
public static void debugLog(@NotNull String... logs) {
|
||||
if (!devMode) {
|
||||
for (String log : logs) {
|
||||
debugLogs.add("[DEBUG] " + log);
|
||||
}
|
||||
return;
|
||||
}
|
||||
StackTraceElement stackTraceElement = new Throwable().getStackTrace()[1];
|
||||
@@ -299,32 +301,8 @@ public class Util {
|
||||
String methodName = stackTraceElement.getMethodName();
|
||||
int codeLine = stackTraceElement.getLineNumber();
|
||||
for (String log : logs) {
|
||||
String text =
|
||||
"["
|
||||
+ ChatColor.DARK_GREEN
|
||||
+ ChatColor.BOLD
|
||||
+ "DEBUG"
|
||||
+ ChatColor.RESET
|
||||
+ "] ["
|
||||
+ ChatColor.DARK_GREEN
|
||||
+ className
|
||||
+ ChatColor.RESET
|
||||
+ "]"
|
||||
+ " ["
|
||||
+ ChatColor.DARK_GREEN
|
||||
+ methodName
|
||||
+ ChatColor.RESET
|
||||
+ "] ("
|
||||
+ ChatColor.DARK_GREEN
|
||||
+ codeLine
|
||||
+ ChatColor.RESET
|
||||
+ ") "
|
||||
+ log;
|
||||
debugLogs.add(Colorizer.stripColors(text));
|
||||
if (debugLogs.size() > 2000) /* Keep debugLogs max can have 2k lines. */ {
|
||||
debugLogs.clear();
|
||||
}
|
||||
QuickShop.instance.getLogger().info(text);
|
||||
debugLogs.add("[DEBUG] [" + className + "] [" + methodName + "] (" + codeLine + ") " + log);
|
||||
QuickShop.instance.getLogger().info(log);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user