[WIP] Fix race between flush and Emit.

Emit() may be called from multiple goroutine.
flush() is also called from anther goroutine.
To protect buffer from race, single goroutine should handle all emit() and flush().

WIP: I have not run this code yet. Hopefully, I'll test in this week.