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

TracingPrintStream not useful for Exception.printStackTrace etc. #641

@Player3324

Description

@Player3324

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions