Skip to content
This repository has been archived by the owner on May 26, 2018. It is now read-only.

Commit

Permalink
Patch TracingPrintStream to handle Kotlin IO.
Browse files Browse the repository at this point in the history
Kotlins internal IO suite wraps the old System.out style, so descend
deeper in the stack when kotlin.io is detected.
  • Loading branch information
Emberwalker authored and cpw committed Apr 11, 2015
1 parent 10ac2a4 commit 86f70d3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/cpw/mods/fml/common/TracingPrintStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
public class TracingPrintStream extends PrintStream {

private Logger logger;
private int BASE_DEPTH = 3;

public TracingPrintStream(Logger logger, PrintStream original) {
super(original);
Expand All @@ -39,7 +40,10 @@ public void println(String s) {

private String getPrefix() {
StackTraceElement[] elems = Thread.currentThread().getStackTrace();
StackTraceElement elem = elems[3]; // The caller is always at depth 2, plus this call.
StackTraceElement elem = elems[BASE_DEPTH]; // The caller is always at BASE_DEPTH, including this call.
if (elem.getClassName().startsWith("kotlin.io.")) {
elem = elems[BASE_DEPTH + 2]; // Kotlins IoPackage masks origins 2 deeper in the stack.
}
return "[" + elem.getClassName() + ":" + elem.getMethodName() + ":" + elem.getLineNumber() + "]: ";
}

Expand Down

0 comments on commit 86f70d3

Please sign in to comment.