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.
Move icbd_ioerr before the dispatch
Make sure the we don't overflow the logfiles table