mirror of
https://github.com/shadowfacts/lwjgl2-arm64.git
synced 2026-04-05 14:35:58 +00:00
Implemented proper debug levels
This commit is contained in:
parent
aae1deef70
commit
fb8fd0a2d7
27 changed files with 207 additions and 194 deletions
|
|
@ -80,9 +80,7 @@ public final class Display {
|
|||
static {
|
||||
System.loadLibrary(Sys.getLibraryName());
|
||||
init();
|
||||
if (Sys.atDebugLevel()) {
|
||||
System.out.println("Adapter: "+getAdapter()+" Version: "+getVersion());
|
||||
}
|
||||
Sys.log(Sys.DEBUG, "Adapter: "+getAdapter()+" Version: "+getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -120,9 +118,7 @@ public final class Display {
|
|||
DisplayMode[] filteredModes = new DisplayMode[modes.size()];
|
||||
modes.toArray(filteredModes);
|
||||
|
||||
if (Sys.atDebugLevel()) {
|
||||
System.out.println("Removed " + (unfilteredModes.length - filteredModes.length) + " duplicate displaymodes");
|
||||
}
|
||||
Sys.log(Sys.DEBUG, "Removed " + (unfilteredModes.length - filteredModes.length) + " duplicate displaymodes");
|
||||
|
||||
return filteredModes;
|
||||
}
|
||||
|
|
@ -239,9 +235,7 @@ public final class Display {
|
|||
gammaRamp.put(i, rampEntry);
|
||||
}
|
||||
setGammaRamp(gammaRamp);
|
||||
if (Sys.atDebugLevel()) {
|
||||
System.out.println("Gamma set, gamma = " + gamma + ", brightness = " + brightness + ", contrast = " + contrast);
|
||||
}
|
||||
Sys.log(Sys.DEBUG, "Gamma set, gamma = " + gamma + ", brightness = " + brightness + ", contrast = " + contrast);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -48,8 +48,12 @@ import org.lwjgl.input.Mouse;
|
|||
*/
|
||||
public final class Sys {
|
||||
/** Debug level constants */
|
||||
public static final int DEBUG_DISABLED = 1;
|
||||
public static final int DEBUG_ENABLED = 2;
|
||||
public static final int DEBUG = 6;
|
||||
public static final int INFO = 5;
|
||||
public static final int WARN = 4;
|
||||
public static final int ERROR = 3;
|
||||
public static final int FATAL = 2;
|
||||
public static final int NONE = 1;
|
||||
|
||||
/** Low process priority. @see #setProcessPriority() */
|
||||
public static final int LOW_PRIORITY = -1;
|
||||
|
|
@ -84,22 +88,28 @@ public final class Sys {
|
|||
private static String LIBRARY_NAME = "lwjgl";
|
||||
|
||||
/**
|
||||
* Debug level. This will tell you if you are using the debug version of
|
||||
* the library, and whether assertions are enabled or not.
|
||||
* Debug level.
|
||||
*/
|
||||
public static final int DEBUG;
|
||||
public static final int debug_level;
|
||||
|
||||
static {
|
||||
int _debug = DEBUG_DISABLED;
|
||||
try {
|
||||
assert false;
|
||||
} catch (AssertionError e) {
|
||||
// Assertions are enabled, so we'll enabled debugging
|
||||
_debug = DEBUG_ENABLED;
|
||||
} finally {
|
||||
DEBUG = _debug;
|
||||
initialize();
|
||||
String debug_level_prop = System.getProperty("lwjgl.debuglevel", "NONE");
|
||||
int _debug = NONE;
|
||||
if (debug_level_prop.equals("DEBUG")) {
|
||||
_debug = DEBUG;
|
||||
} else if (debug_level_prop.equals("INFO")) {
|
||||
_debug = INFO;
|
||||
} else if (debug_level_prop.equals("WARN")) {
|
||||
_debug = WARN;
|
||||
} else if (debug_level_prop.equals("ERROR")) {
|
||||
_debug = ERROR;
|
||||
} else if (debug_level_prop.equals("FATAL")) {
|
||||
_debug = FATAL;
|
||||
} else if (debug_level_prop.equals("NONE")) {
|
||||
_debug = NONE;
|
||||
}
|
||||
debug_level = _debug;
|
||||
initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -114,9 +124,21 @@ public final class Sys {
|
|||
*/
|
||||
private Sys() {
|
||||
}
|
||||
|
||||
public static boolean atDebugLevel() {
|
||||
return DEBUG >= DEBUG_ENABLED;
|
||||
|
||||
/**
|
||||
* Prints the given message to System.err if atDebugLevel(debug_level)
|
||||
* is true.
|
||||
*/
|
||||
public static void log(int debug_level, String msg) {
|
||||
if (atDebugLevel(debug_level))
|
||||
System.err.println(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the debug level is greater than or equal to level
|
||||
*/
|
||||
public static boolean atDebugLevel(int level) {
|
||||
return debug_level >= level;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -124,7 +146,7 @@ public final class Sys {
|
|||
*/
|
||||
private static void initialize() {
|
||||
System.loadLibrary(LIBRARY_NAME);
|
||||
setDebugLevel(DEBUG);
|
||||
setDebugLevel(debug_level);
|
||||
setTime(0);
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
|
|
|
|||
|
|
@ -142,9 +142,7 @@ public abstract class BaseAL {
|
|||
private static String getPathFromJWS(String libname) {
|
||||
try {
|
||||
|
||||
if(Sys.atDebugLevel()) {
|
||||
System.out.println("JWS Classloader looking for: " + libname);
|
||||
}
|
||||
Sys.log(Sys.DEBUG, "JWS Classloader looking for: " + libname);
|
||||
|
||||
Object o = BaseAL.class.getClassLoader();
|
||||
Class c = o.getClass();
|
||||
|
|
@ -154,10 +152,7 @@ public abstract class BaseAL {
|
|||
return (String) findLibrary.invoke(o, arguments);
|
||||
|
||||
} catch (Exception e) {
|
||||
if(Sys.atDebugLevel()) {
|
||||
System.out.println("Failure locating OpenAL using classloader:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
Sys.log(Sys.INFO, "Failure locating OpenAL using classloader:" + e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,15 +162,11 @@ public abstract class GLCaps {
|
|||
}
|
||||
|
||||
private static void setExtensionFields(HashSet exts, HashMap field_map) {
|
||||
if(org.lwjgl.Sys.atDebugLevel()) {
|
||||
System.out.println("Available extensions:");
|
||||
}
|
||||
Sys.log(Sys.DEBUG, "Available extensions:");
|
||||
Iterator it = exts.iterator();
|
||||
while (it.hasNext()) {
|
||||
String ext = (String)it.next();
|
||||
if(org.lwjgl.Sys.atDebugLevel()) {
|
||||
System.out.println(ext);
|
||||
}
|
||||
Sys.log(Sys.DEBUG, ext);
|
||||
|
||||
Field f = (Field)field_map.get(ext);
|
||||
if (f != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue