Add some debug logging.

As part of this, DEBUG=1 needed to be defined for Debug builds.