Skip to content

Commit

Permalink
Logging line numbers when in debug mode (#117)
Browse files Browse the repository at this point in the history
* Logging line numbers when in debug mode

* Utilize `RunConfig#isGroovyFile` in checking for names
  • Loading branch information
Rongmario authored Feb 16, 2024
1 parent 111431d commit a05eb11
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ private String getSource() {
ModContainer mod = Loader.instance().activeModContainer();
return mod != null ? mod.getModId() : GroovyScript.ID;
}
if (isDebug()) { // Find line number when debug is on
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
if (element.getFileName() == null) {
continue;
}
if (RunConfig.isGroovyFile(element.getFileName())) {
source += (":" + element.getLineNumber());
break;
}
}
}
return source;
}

Expand Down

0 comments on commit a05eb11

Please sign in to comment.