Rewrite logger_dispatch to use bufferevents to simplify error processing
This also ensures that we're dealing with partial messages correctly and don't get out of sync with the main process.