Moved logging setup before bits that may need logging
Pass dumpdir as parameter rather than using global variable, fixes #12