Debugging loooooong printouts

dj_d

Member
When I'm working on a script with lots of iterations and a print in every one, it's hard to go back and see what's happened before. Two ideas for a solution:
- configurable buffer length in kolmafia so I could just scroll back (very simple)
- ability to print to a plain text file (better, since it's searchable)
it's a pain to look at the session log since I have to end the mafia session first.

Suggestions/fixes welcome! :)
 

Veracity

Developer
Staff member
- configurable buffer length in kolmafia so I could just scroll back (very simple)
You are referring to the gCLI buffer?

I recently made the length of that internally configurable. It uses a "LimitedSizeChatBuffer", which stores its contents in HTML. When you add a line to the end, it has to search the HTML tree to find the end and insert there - and if you have thousands of little lines, that takes a noticeable amount of time, apparently, and people start complaining about how KoLmafia pegs their CPU. I suppose it wouldn't hurt to have that be user configurable, with the default being the current 25,000 characters. If somebody boosts it up and doesn't like the response time when it gets full, they have nobody to blame but themselves.

- ability to print to a plain text file (better, since it's searchable)
I suppose this wouldn't be a security hole if we restricted it to be in the data folder.

it's a pain to look at the session log since I have to end the mafia session first.
Huh? I look at the session log all the time while the session is underway. I have to reload it in order to see new lines that have been appended, but that works just fine for me.
 

DaMaster0

Member
I've never used this function before, but couldn't you just replace the script with an addition to a map? Then you could use map_to_file(), and get it into a text file. (if that's what map_to_file does, I've never used it, I am just assuming that)
 

Bale

Minion
That is what map_to_file() does, but it would be a serious pain in the ass to set up something like that for debugging. Not a good work-around.

Huh? I look at the session log all the time while the session is underway. I have to reload it in order to see new lines that have been appended, but that works just fine for me.
Me too! dj_d, have you actually tried this? Or did you just fail to reload the file to see what was appended most recently?
 

dj_d

Member
Hm. There's a file called active_session.1 in the directory, and I assumed that was the active session (silly me :) ). But it appears the actual session is there, and openable! Yay.

So problem solved, but it would certainly be neat to have something like:

each script can create, delete, and append to a file called scriptfilename.html.

Create might be implicit on append. Delete is important since you would want to be able to blow away the file each execution (or not) based on the situation. Restricting the filename to match the name of the script is an extra layer of protection against malicious (or incompetent) scripting. HTML is nice because you can format for easy reading, and because it complements the existing logfile's text-only functionality.
 
Last edited:

dj_d

Member
Jason, can you elaborate? I tried:
mirror foo.txt
print test
mirror close
but I couldn't find foo.txt.
 

jasonharper

Developer
The mirror file should appear in mafia's root directory - the one that contains the scripts, data, settings, and other folders.
 

dj_d

Member
OK, I see how it works. Note to self: don't name your test script "mirror test.ash". Or you will confuse yourself. :)

This is still pretty far from what I'd like to do - it prints to the screen and to the file, and you can't name the file ".html". I want to be able to create a pretty summary of what the script does, separate from the dump to screen. Any way to make that happen?
 
Top