wurstscript / WurstScript

Programming language and toolkit to create Warcraft III Maps
https://wurstlang.org
Apache License 2.0
225 stars 30 forks source link

Truncate oversized stacktraces #564

Open Frotty opened 6 years ago

Frotty commented 6 years ago

When the stacktrace is very long it can be displayed out of screen and overlap the minimap and other text messages, therefore being unreadable. I think we can sacrifice anything over 7-10 steps for the sake of visibility.

If we ever use a Logger with an output buffer, only the displayed message of the trace could be truncated and the full accessed from the logger.

Cokemonkey11 commented 6 years ago

Possibly worth splitting them into groups of 7-10? Fixes the problem of overlapping minimap buffer, but also allows you to get extra diags in single-player mode from the log.

Frotty commented 6 years ago

They work fine in singleplayer since they are always complete in the Log

Cokemonkey11 commented 6 years ago

I think we can sacrifice anything over 7-10 steps for the sake of visibility.

They work fine in singleplayer since they are always complete in the Log

It sounds to me like you're saying you're removing the complete log

Frotty commented 6 years ago

okay i misunderstood. The existing print works in log, splitting it to multiple print calls could work. This could also be implemented by the stdlib

Cokemonkey11 commented 6 years ago

Maybe normal print function shouldn't incur an overhead like that

peq commented 6 years ago

This could also be implemented by the stdlib

yes, but I think that would require access to the stacktrace-information directly instead of just the getStackTraceString function. I would suggest to replace getStackTraceString() returns string with two new functions: getStackTraceSize() returns int and getStackTraceFrame(int frame) returns string.

With these functions getStackTraceString can be implemented in the standard library.

The current implementation would be something like this:

public function getStackTraceString() returns string
    int i = getStackTraceSize() - 1
    int limit = 0
    string s = ""
    while i > 0 and limit < 20
        i--
        limit++
        s += "\n   " + getStackTraceFrame(i)
    return s

For a quicker fix we can also just change the maximum stack trace size here: https://github.com/wurstscript/WurstScript/blob/master/de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/translation/imtranslation/StackTraceInjector2.java#L21

Frotty commented 6 years ago

Even with just the string you can split it at a linebreak? But sure, more control can't hurt.

peq commented 6 years ago

First joining it and then breaking it seems a bit stupid, but would work.

On Oct 18, 2017 23:38, "Frotty" notifications@github.com wrote:

Even with just the string you can split it at a linebreak? But sure, more control can't hurt.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/wurstscript/WurstScript/issues/564#issuecomment-337735561, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBaksWtvqsWpyDfcKRwOxZRFP89SFsuks5stm-4gaJpZM4P7ULE .