Add support for using a callback for writing debug messages