Here’s a tool which lets AppleScript and anything else which can run a shell command make an entry in Sierra’s logs.
How to run a shell command with root privileges from with Swift. The roundabout way.
Did Marco Marsala really wipe his complete company out with an error in a command?
How can I undo Terminal commands?
How can I use the sudo command from a non-admin user account?