Clean up logger.[ch], don't break backwards compat, fix buf alloc