Skip to content
This repository has been archived by the owner on May 26, 2018. It is now read-only.
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

Description

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.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions