Any way to write to log stream from a Server Script?

Apparently the usual Python print() command is prohibited in a Server Script.

As a work around I am using …

msg = []
msg.append(f"some{thing}, ")
msg.append("something {else}, ")
frappe.msgprint( msg = ''.join(msg), title = 'Debug Log' )

… so as to build up usefully large snapshots of what’s going on in my code.

It’s pretty horrible.

Is there a better alternative?

Alternatively, how can I call into my whitelisted functionality?

Did you try frappe.logger()

used like this:

It would have been nice, but I get :

AttributeError: module has no attribute 'logger'

I was hoping this list of RestrictedPython commands was out of date. Seems not.

I really don’t get it. I seem to able to effect some fairly drastic changes to the database through a Server Script, but writing to a log file, “Oh, NO! Much too insecure!”

Weird!