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

TracingPrintStream not useful for Exception.printStackTrace etc. #641

Open
sfPlayer1 opened this issue Apr 19, 2015 · 0 comments
Open

TracingPrintStream not useful for Exception.printStackTrace etc. #641

sfPlayer1 opened this issue Apr 19, 2015 · 0 comments

Comments

@sfPlayer1
Copy link
Contributor

Some invocations currently result in messages like this:
[12:22:04] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:748]: ...

I'd change it as follows to be less dependent on directly invoking System.out/err.println:

private String getPrefix() {
    StackTraceElement[] elems = Thread.currentThread().getStackTrace();
    int start = BASE_DEPTH;
    StackTraceElement elem = elems[start];

    while (elem.getClassName().equals("net.minecraftforge.fml.common.TracingPrintStream") ||
            elem.getClassName().startsWith("java.") ||
            elem.getClassName().startsWith("kotlin.io.")) {
        start++;

        if (start >= elems.length) {
            elem = elems[BASE_DEPTH];
            break;
        } else {
            elem = elems[start];
        }
    }

    return "[" + elem.getClassName() + ":" + elem.getMethodName() + ":" + elem.getLineNumber() + "]: ";
}

BASE_DEPTH could be removed/replaced by 0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant