Use debug() instead of console.error()

Silents the module by default and also prints the has_error
boolean in case its wanted. Ideally there would be a way
to catch 'end' and 'close' upstream.