I am looking for generic bash (could be python also) wrapper that can be used to be called instead of the original program and that will call the original program and:
- logs the calling command line
- logs stdout and stderr, but without hiding them from the caller
- be transparent – have the same stdout as the called program
- return the exit code of the called program
The answer would be a functional script, here is the “prototype”
#!/bin/bash
LOGFILE=history.log
ORIGINAL=ls
touch ${LOGFILE}
echo "started" >>"${LOGFILE}"
ls "$@"
echo "ended with $?" >>"${LOGFILE}”
Also at https://gist.github.com/2411440