Add debug logging

Add the ability to enable debug logging to console (enabled in committed version, disabled for publish to NPM)