rename poorly named variable
Add debug-log setting to log everything when stderr is redirected to file
Based on code from BFGMiner