refactor buffer API,fix log bugs