Actually fix the debugging logic

Expose a helper function that allows pkg(1) to set the debug level.

The previous "attempt" at fixing this was waaay too hasty and I didn't even compile test it because the fix looked simple enough that it should be dry-coded successfully.  This fixes the build problem and has been actually tested.  `pkg -ddd` now behaves as expected.

Pointy Hat To: seanc@