Fixed logging script for declare/define commands

The logging script first logged the interaction before delegating it to the
underlying script.  If the underlying script throws an exception, the command is
still logged.  This is desired for most commands, but leads to multiply defined
symbols if declareFun is used to check if a function symbol is already declared.
Now, we don't log this interaction anymore.  We first delay the call to the
underlying script and log the command only if the underlying script did not
throw an exception.