Add config to only log GL errors once
This commit is contained in:
@@ -1015,9 +1015,23 @@ public class Config
|
||||
public static class OpenGl
|
||||
{
|
||||
public static ConfigEntry<Boolean> overrideVanillaGLLogger = new ConfigEntry.Builder<Boolean>()
|
||||
.set(ModInfo.IS_DEV_BUILD)
|
||||
.set(true)
|
||||
.comment(""
|
||||
+ "Requires a reboot to change. \n"
|
||||
+ "Defines how OpenGL errors are handled. \n "
|
||||
+ "Requires rebooting Minecraft to change. \n"
|
||||
+ "Will catch OpenGL errors thrown by other mods. \n"
|
||||
+ "")
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Boolean> onlyLogGlErrorsOnce = new ConfigEntry.Builder<Boolean>()
|
||||
.set(true)
|
||||
.comment(""
|
||||
+ "If true each Open GL error will only be logged once. \n"
|
||||
+ "Enabling this may cause some error logs to be missed. \n"
|
||||
+ "Does nothing if overrideVanillaGLLogger is set to false. \n"
|
||||
+ " \n"
|
||||
+ "Generally this can be kept as 'true' to prevent log spam. \n"
|
||||
+ "However, Please set this to 'false' if a developer needs your log to debug a GL issue. \n"
|
||||
+ "")
|
||||
.build();
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@ import org.lwjgl.opengl.GLCapabilities;
|
||||
import org.lwjgl.opengl.GLUtil;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
/**
|
||||
@@ -52,6 +56,10 @@ public class GLProxy
|
||||
public static final ConfigBasedLogger GL_LOGGER = new ConfigBasedLogger(LogManager.getLogger(GLProxy.class),
|
||||
() -> Config.Common.Logging.logRendererGLEvent.get());
|
||||
|
||||
public static final Set<String> LOGGED_GL_MESSAGES = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
|
||||
|
||||
|
||||
|
||||
private static GLProxy instance = null;
|
||||
|
||||
|
||||
@@ -279,8 +287,19 @@ public class GLProxy
|
||||
}
|
||||
|
||||
|
||||
|
||||
boolean onlyLogOnce = Config.Client.Advanced.Debugging.OpenGl.onlyLogGlErrorsOnce.get();
|
||||
String errorMessage = "GL ERROR [" + msg.id + "] from [" + msg.source + "]: [" + msg.message + "]"+(onlyLogOnce ? " this message will only be logged once" : "")+".";
|
||||
if (onlyLogOnce
|
||||
&& !LOGGED_GL_MESSAGES.add(errorMessage))
|
||||
{
|
||||
// this message has already been logged
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// create an exception so we get a stacktrace of where the message was triggered from
|
||||
RuntimeException exception = new RuntimeException("GL ERROR [" + msg.id + "] from [" + msg.source + "]: [" + msg.message + "].");
|
||||
RuntimeException exception = new RuntimeException(errorMessage);
|
||||
|
||||
if (msg.type == EGLMessageType.ERROR || msg.type == EGLMessageType.UNDEFINED_BEHAVIOR)
|
||||
{
|
||||
|
||||
@@ -477,7 +477,11 @@
|
||||
"distanthorizons.config.client.advanced.debugging.openGl.overrideVanillaGLLogger":
|
||||
"Override Vanilla GL Logger",
|
||||
"distanthorizons.config.client.advanced.debugging.openGl.overrideVanillaGLLogger.@tooltip":
|
||||
"Defines how OpenGL errors are handled. \n Requires rebooting Minecraft to apply. \nMay incorrectly catch OpenGL errors thrown by other mods.",
|
||||
"Defines how OpenGL errors are handled. \nRequires rebooting Minecraft to change. \nWill catch OpenGL errors thrown by other mods.",
|
||||
"distanthorizons.config.client.advanced.debugging.openGl.onlyLogGlErrorsOnce":
|
||||
"Only Log GL Errors Once",
|
||||
"distanthorizons.config.client.advanced.debugging.openGl.onlyLogGlErrorsOnce.@tooltip":
|
||||
"If true each Open GL error will only be logged once. \nTEnabling this may cause some error logs to be missed. \nDoes nothing if overrideVanillaGLLogger is set to false. \n\nGenerally this can be kept as 'true' to prevent log spam. \nHowever, Please set this to 'false' if a developer needs your log to debug a GL issue. \n",
|
||||
"distanthorizons.config.client.advanced.debugging.openGl.glErrorHandlingMode":
|
||||
"OpenGL Error Handling Mode",
|
||||
"distanthorizons.config.client.advanced.debugging.openGl.glErrorHandlingMode.@tooltip":
|
||||
|
||||
Reference in New Issue
Block a user