Feature Allow print_html to print output to the session log

Irrat

Member
Not sure if this is a bug or a feature request, but basically print will write to the session log, while print_html doesn't.

Generally as a rule, scripts use print_html to print spammy stuff, stuff that you don't really care to see in session log. But sometimes it's still you do want to see, such as when a script prints something informative and decorated that text.

As for what the boolean would represent, we could either introduce the new default behavior of print_html output in session log, and the boolean prevents the text being written to session log.
Or we could have the default behavior to be as it is now, that html is not written to session log and you use the boolean to tell mafia that the string is safe to print to session log.

Now I'd normally argue that the default behavior should definitely be opt-in, that is; The script has to explicitly tell mafia to write to session logs.
However print already writes to session logs. Having print_html differ feels a bit weird.

Changing the default behavior of print is also a bad idea, as it could potentially break scripts, and would break known behavior.

Finally, the question if the string written should be stripped html or the raw html. I think it should be stripped html, as session log is generally meant to be readable.
Although this could be controlled by a property?
 

fronobulax

Developer
Staff member
A recent PR made it so the mirror command would send HTML sent to the gCLI to the mirror file as well. So this functionality is already available provided the gCLI output is mirrored and the mirror file is "processed" instead of the session log.

If implemented I would want to make sure print_html when mirrored did not produce a duplicate "entry".

There is definitely a philosophy issue here. I want a log file that is human readable and can be processed by command line text processing tools - grep, gawk, etc. If he session log is this file then allowing html to be written to it is already not especially desirable. This just makes the situation worse. IMO. YMMV.
 

Irrat

Member
A recent PR made it so the mirror command would send HTML sent to the gCLI to the mirror file as well. So this functionality is already available provided the gCLI output is mirrored and the mirror file is "processed" instead of the session log.

If implemented I would want to make sure print_html when mirrored did not produce a duplicate "entry".

There is definitely a philosophy issue here. I want a log file that is human readable and can be processed by command line text processing tools - grep, gawk, etc. If he session log is this file then allowing html to be written to it is already not especially desirable. This just makes the situation worse. IMO. YMMV.
The session log is not related to the mirror thing in the manner you seem to believe. Calling print() explicitly logs to session log, the area which generally all gCLI logging is done is not connected to session log aside from having code in the same class.

That is to say, there's no risk of duplicate entries to session log if print_html was modified. Calls to session log requires an explicit mention, no secret parameter, no hidden method calls. Just updateSessionLog(final String line)

As for readable, I suggested at the end about stripping out the html as we already do in RequestPane's copy as html = false. We might do this in other areas as well.
 

lostcalpolydude

Developer
Staff member
I would want the default behavior of print_html() to stay as is, rather than having to go back and change scripts that I wrote a decade ago with the explicit goal of not spamming up session logs with output that is only useful for the user to look at in the moment.
 

ckb

Minion
Staff member
I agree to keeping the default as no-session, but would welcome the ability to add session print_html() to my scripts.
Often I want to add color and flair to my output (like coloring elemental values) and then review that in session logs. A print_html(string text, boolean session) option would be nice.
 

fronobulax

Developer
Staff member
I am going to prefer not to use unmodified versions of a script that spams my session log with HTML. That breaks my tools and workflow.

I maintain, possibly due to misunderstanding, that the existing print_html can spam HTML to the gCLI. The existing mirror command can capture this spammed HTML as HTML in a mirror file because mirror captures the gCLI.. So the capability already exists for users that are willing to use a mirror file instead of a session log file.

I am not personally going to implement this and write tests. I will however be somewhat supportive at approval time so long as the tests show the gCLI, session log and mirror file as I expect.
 
Top