mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-24 05:24:59 +02:00
Fixed DebugUtils
This commit is contained in:
parent
871cb993b4
commit
014bc8b0b5
|
@ -11,15 +11,11 @@ public final class DebugUtils {
|
||||||
public final static Logger LOGGER = LoggerFactory.getLogger(DebugUtils.class);
|
public final static Logger LOGGER = LoggerFactory.getLogger(DebugUtils.class);
|
||||||
|
|
||||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||||
private static final int OFFSET = 2; // Used to do not show DebugUtils in the stack trace
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the current thread stack trace elements.
|
* Prints the current thread stack trace elements.
|
||||||
*
|
|
||||||
* @param maxLine the maximum number of stack trace element
|
|
||||||
*/
|
*/
|
||||||
public static synchronized void printStackTrace(int maxLine) {
|
public static synchronized void printStackTrace() {
|
||||||
maxLine += OFFSET;
|
|
||||||
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
|
StackTraceElement[] elements = Thread.currentThread().getStackTrace();
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
@ -27,7 +23,7 @@ public final class DebugUtils {
|
||||||
stringBuilder.append("START STACKTRACE");
|
stringBuilder.append("START STACKTRACE");
|
||||||
stringBuilder.append(LINE_SEPARATOR);
|
stringBuilder.append(LINE_SEPARATOR);
|
||||||
|
|
||||||
for (int i = OFFSET; i < maxLine; i++) {
|
for (int i = 0; i < Integer.MAX_VALUE; i++) {
|
||||||
if (i >= elements.length)
|
if (i >= elements.length)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -42,11 +38,4 @@ public final class DebugUtils {
|
||||||
LOGGER.info(stringBuilder.toString());
|
LOGGER.info(stringBuilder.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints the current thread stack trace elements.
|
|
||||||
*/
|
|
||||||
public static synchronized void printStackTrace() {
|
|
||||||
printStackTrace(Integer.MAX_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user