Feature Option to save stack traces to session log

taltamir

Member
When a script (for example autoscend) runs into an error in mafia it will print a stack trace into the gCLI, but the stack trace will not be saved into the session log, instead being only in the gCLI for a short amount of time before being lost. This is particularly pertinent for autoscend because sometimes it can recover from stack trace inducing errors and continue to truck on to do other things. causing the stack trace to be quickly lost.

It would be great if there was an option to save those stack traces into the session log file for later perusal. Also because copy pasting from the gCLI itself tend to mess up text by adding a bunch of random whitespace.
I asked around and the people I talked to do not know of a way to make it happen so I figured this would be a new feature request.
 

fronobulax

Developer
Staff member
Early in my morning and my coffee has not kicked in. Random thoughts that might be obviously irrelevant if I spent more time on them :)

Does the mirror command capture the information you want, in the mirror file?

Are these the ash stack traces generated when ash finds something or Java stack traces generated by a varieto of causes or both?

If a FR to have everything printed to the gCLI also written to the session log were implemented would that address this? Note such a FR has been considered but since the gCLI supports and renders HTML and the session log doesn't an ideal implementation would be somewhat nuanced about how it handled HTML.

It might take me a couple days - even with COVID-19 restrictions there are still deadlines - but it seems to me to be reasonable and within my capabilities :)
 

taltamir

Member
Does the mirror command capture the information you want, in the mirror file?
Huh, never knew that this is a thing. testing it, it indeed captures what i am looking for. which is something like
Code:
nextAdventure => Noob Cave
customCombatScript is set to unrecognized 'aftercore', should be 'autoscend_null'
Stack trace:
  at main (auto_pre_adv.ash:15)
Stack trace:
  at rainManSummon (auto_heavyrains.ash:522)
  at rainManSummon (auto_heavyrains.ash:544)
  at hr_initializeDay (auto_heavyrains.ash:152)
  at initializeDay (autoscend.ash:1435)
  at auto_begin (autoscend.ash:5195)
  at safe_preference_reset_wrapper (autoscend.ash:5332)
  at safe_preference_reset_wrapper (autoscend.ash:5339)
  at safe_preference_reset_wrapper (autoscend.ash:5339)
  at safe_preference_reset_wrapper (autoscend.ash:5339)
printStackOnAbort => false

====

Are these the ash stack traces generated when ash finds something or Java stack traces generated by a varieto of causes or both?
ash please

If a FR to have everything printed to the gCLI also written to the session log were implemented would that address this? Note such a FR has been considered but since the gCLI supports and renders HTML and the session log doesn't an ideal implementation would be somewhat nuanced about how it handled HTML.
I don't think we actually need the HTML (unless the stack trace it prints for ash is in HTML and i just didn't notice?)
But I won't complain if it captures some HTML alongside the stack trace.
The output from the mirror file actually looks quite good. actually i think it is capturing HTML in mirror already
for example
Code:
<font color="blue">[INFO] - Looking to summon: lobsterfrogman</font>
======

It might take me a couple days - even with COVID-19 restrictions there are still deadlines - but it seems to me to be reasonable and within my capabilities :)
thank you
 
Last edited:

fronobulax

Developer
Staff member
Not sure about this :-( What I am seeing is that some of the errors generate a ScriptException and that is thrown and processed as a Java exception. Clearly the java output stream is ending up in the gCLI but I'm not sure how to tell Java to print ScriptExceptions to two places but otherwise not effect other unhandled exceptions. Still pondering but not hopeful.
 

Veracity

Developer
Staff member
He's looking for the ASH stack trace, not the Java stack trace.
That is printed whenever the script aborts and the interpreter goes into the EXIT state and unwinds.

He said that the mirror command captures what he wants.

The question is how to have it go to the session log as well as the gCLI.
And whether it should always do that, or if there should be a setting or something to control it.

Interpreter.java:

Code:
	public void setState( final String state )
	{
		this.currentState = state;

		if (state.equals(STATE_EXIT) && Preferences.getBoolean( "printStackOnAbort" ) )
		{
			this.printStackTrace();
		}
	}
 

fronobulax

Developer
Staff member
I understand. The first thing I did was add a second "write" to the above referenced printStackTrace. I did not see what I expected. One of my tests was to divide by zero in ash. That gave me a gCLI ash stack trace but nothing else. As near as I can figure the arithmetic exceptions are thrown for Java to deal with and not printed by any mafia code. Hence my comments above. At this point it seems that there is more than one type of ash exception and my hope of not having to make a distinction is fading.
 

taltamir

Member
Somewhat related for getting better logs.
There is a log preferences change option. is there a way to have it enabled while excluding one single preference called maximizerMRUList
most preference changes are one line long but this one is several pages.
having preference change logging helps debugging, particularly for NC adventure handling. But it makes the log very messy with multiple pages of that one setting per each adventure spent.
 
Last edited:

fronobulax

Developer
Staff member
r20019 unconditionally echos stack traces to the session log, if mafia was printing the trace. Lightly tested.

The trace caused by

about("your message here");

does appear in the log but the trace caused by

int i = 1/0;

does not.
 
Top