Reduced Sys.debug from bool -> int

This commit is contained in:
Elias Naur 2003-12-20 22:03:25 +00:00
parent fb8fd0a2d7
commit 790b01a01b
27 changed files with 181 additions and 212 deletions

View file

@ -80,7 +80,7 @@ public final class Display {
static {
System.loadLibrary(Sys.getLibraryName());
init();
Sys.log(Sys.DEBUG, "Adapter: "+getAdapter()+" Version: "+getVersion());
Sys.log("Adapter: "+getAdapter()+" Version: "+getVersion());
}
/**
@ -118,7 +118,7 @@ public final class Display {
DisplayMode[] filteredModes = new DisplayMode[modes.size()];
modes.toArray(filteredModes);
Sys.log(Sys.DEBUG, "Removed " + (unfilteredModes.length - filteredModes.length) + " duplicate displaymodes");
Sys.log("Removed " + (unfilteredModes.length - filteredModes.length) + " duplicate displaymodes");
return filteredModes;
}
@ -235,7 +235,7 @@ public final class Display {
gammaRamp.put(i, rampEntry);
}
setGammaRamp(gammaRamp);
Sys.log(Sys.DEBUG, "Gamma set, gamma = " + gamma + ", brightness = " + brightness + ", contrast = " + contrast);
Sys.log("Gamma set, gamma = " + gamma + ", brightness = " + brightness + ", contrast = " + contrast);
}
/**

View file

@ -47,14 +47,6 @@ import org.lwjgl.input.Mouse;
* @version $Revision$
*/
public final class Sys {
/** Debug level constants */
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;
@ -90,25 +82,14 @@ public final class Sys {
/**
* Debug level.
*/
public static final int debug_level;
public static final boolean debug;
static {
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;
String debug_level_prop = System.getProperty("org.lwjgl.Sys.debug", "false");
if (debug_level_prop.equals("true"))
debug = true;
else
debug = false;
initialize();
}
@ -126,19 +107,19 @@ public final class Sys {
}
/**
* Prints the given message to System.err if atDebugLevel(debug_level)
* Prints the given message to System.err if isDebugEnabled()
* is true.
*/
public static void log(int debug_level, String msg) {
if (atDebugLevel(debug_level))
public static void log(String msg) {
if (isDebugEnabled())
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;
public static boolean isDebugEnabled() {
return debug;
}
/**
@ -146,7 +127,7 @@ public final class Sys {
*/
private static void initialize() {
System.loadLibrary(LIBRARY_NAME);
setDebugLevel(debug_level);
setDebug(debug);
setTime(0);
Runtime.getRuntime().addShutdownHook(new Thread() {
@ -166,7 +147,7 @@ public final class Sys {
/**
* Set the debug level of the native library
*/
private static native void setDebugLevel(int level);
private static native void setDebug(boolean debug);
/**
* Obtains the number of ticks that the hires timer does in a second.

View file

@ -142,7 +142,7 @@ public abstract class BaseAL {
private static String getPathFromJWS(String libname) {
try {
Sys.log(Sys.DEBUG, "JWS Classloader looking for: " + libname);
Sys.log("JWS Classloader looking for: " + libname);
Object o = BaseAL.class.getClassLoader();
Class c = o.getClass();
@ -152,7 +152,7 @@ public abstract class BaseAL {
return (String) findLibrary.invoke(o, arguments);
} catch (Exception e) {
Sys.log(Sys.INFO, "Failure locating OpenAL using classloader:" + e);
Sys.log("Failure locating OpenAL using classloader:" + e);
}
return null;
}

View file

@ -162,11 +162,11 @@ public abstract class GLCaps {
}
private static void setExtensionFields(HashSet exts, HashMap field_map) {
Sys.log(Sys.DEBUG, "Available extensions:");
Sys.log("Available extensions:");
Iterator it = exts.iterator();
while (it.hasNext()) {
String ext = (String)it.next();
Sys.log(Sys.DEBUG, ext);
Sys.log(ext);
Field f = (Field)field_map.get(ext);
if (f != null) {