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!
1 Like
Discovered this challenge myself, yesterday.
These 2 lines of syntax are accepted. They don’t violate RestrictedPython.
log("This is my message")
frappe.log_error("This is my message")
I have no idea where 'log()'
is trying to write to. I haven’t been able to find it. I’ve scanned every file in the ./logs subdirectory. 
The 'log_error()'
does successfully write to the “Error Log” DocType.
1 Like