Add support for SUBMAN_DEBUG to log to stdout

This is optional. I did it for some testing/debugging and found it useful, so this is the cleaned up version.