add logginig code for debug of buffer flush behaviour.