Skip to content

Commit

Permalink
qa: address PMD InvalidLogMessageFormat finding
Browse files Browse the repository at this point in the history
- if I understand https://stackoverflow.com/questions/7102339/is-there-a-correct-way-to-pass-arguments-in-slf4j correctly, this should not be less performant but valid SLF4j format
  • Loading branch information
jdrueckert committed Aug 18, 2024
1 parent a3df04a commit ae226a2
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,24 @@ public class DebugCallback implements org.lwjgl.opengl.GLDebugMessageCallbackI {
@Override
public void invoke(int source, int type, int id, int severity, int length, long message, long userParam) {
String logFormat = "[{}] [{}] [{}] {}";
Object[] args = new Object[]{
"0x" + Integer.toHexString(id).toUpperCase(Locale.ROOT),
getSourceString(source),
getTypeString(type),
MemoryUtil.memASCII(message).trim()
};
String idString = "0x" + Integer.toHexString(id).toUpperCase(Locale.ROOT);
String sourceString = getSourceString(source);
String typeString = getTypeString(type);
String messageString = MemoryUtil.memASCII(message).trim();

switch (severity) {
case GL_DEBUG_SEVERITY_HIGH:
logger.error(logFormat, args);
logger.error(logFormat, idString, sourceString, typeString, messageString);
break;
case GL_DEBUG_SEVERITY_MEDIUM:
logger.warn(logFormat, args);
logger.warn(logFormat, idString, sourceString, typeString, messageString);
break;
case GL_DEBUG_SEVERITY_LOW:
logger.debug(logFormat, args);
logger.debug(logFormat, idString, sourceString, typeString, messageString);
break;
default:
case GL_DEBUG_SEVERITY_NOTIFICATION:
logger.trace(logFormat, args);
logger.trace(logFormat, idString, sourceString, typeString, messageString);
break;
}
}
Expand Down

0 comments on commit ae226a2

Please sign in to comment.