WurstScript icon indicating copy to clipboard operation
WurstScript copied to clipboard

Truncate oversized stacktraces

Open Frotty opened this issue 8 years ago • 8 comments

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.

Frotty avatar Oct 16 '17 22:10 Frotty

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.

Cokemonkey11 avatar Oct 17 '17 19:10 Cokemonkey11

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

Frotty avatar Oct 17 '17 22:10 Frotty

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

Cokemonkey11 avatar Oct 17 '17 23:10 Cokemonkey11

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

Frotty avatar Oct 17 '17 23:10 Frotty

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

Cokemonkey11 avatar Oct 18 '17 20:10 Cokemonkey11

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

peq avatar Oct 18 '17 21:10 peq

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

Frotty avatar Oct 18 '17 21:10 Frotty

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

On Oct 18, 2017 23:38, "Frotty" [email protected] 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 .

peq avatar Oct 18 '17 21:10 peq