Skip to content

Commit

Permalink
Added the option to print stack trace for debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Nov 4, 2022
1 parent 472371e commit f0b9d9c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Expand Up @@ -129,7 +129,9 @@ public enum Debug {
VOID_TELEPORT,
TELEPORT_PLAYER,
LOAD_CHUNK,
PASTE_SCHEMATIC;
PASTE_SCHEMATIC,

SHOW_STACKTRACE;

private static String[] DEBUG_NAMES = null;

Expand Down
Expand Up @@ -49,13 +49,19 @@ public static void error(Throwable error, File file, Object first, Object... par
}

public static void debug(Debug debug, String clazz, String method, Object... params) {
if (isDebugged(debug))
if (isDebugged(debug)) {
entering(clazz, method, null, params);
if (isDebugged(Debug.SHOW_STACKTRACE))
printStackTrace();
}
}

public static void debugResult(Debug debug, String clazz, String method, @Nullable String message, Object result) {
if (isDebugged(debug))
if (isDebugged(debug)) {
entering(clazz, method, message, result);
if (isDebugged(Debug.SHOW_STACKTRACE))
printStackTrace();
}
}

public static void debugResult(Debug debug, String clazz, String method, @Nullable String message, Throwable error) {
Expand All @@ -65,6 +71,10 @@ public static void debugResult(Debug debug, String clazz, String method, @Nullab
}
}

private static void printStackTrace() {
new Exception().printStackTrace();
}

public static void entering(String clazz, String method, @Nullable String message, Object... params) {
enteringInternal(Level.INFO, clazz, method, message, params);
}
Expand Down

0 comments on commit f0b9d9c

Please sign in to comment.