Factor out the debug facility inside a class for reuse.

Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>