Moved wsh_run_cmd and related into library

If we want to allow other clients to run commands, we should expose it in the
library itself, rather than ferretting it away in the server binary
Refactored logging functions