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.

Pointy Hat To: seanc@