func (log *logCache) Write(message []byte) (int, error) {
	log.flushing.Lock()
	defer log.flushing.Unlock()
	if len(message) > 0 {
		messageCopy := make([]byte, len(message))
		copy(messageCopy, message)
		log.messages = append(log.messages, messageCopy)
	}
	return len(message), nil
}
Write caches the passed message. Blocked by flush function.
package tlog
import (
	"io"
	"sync"
)
type logCache struct {
	flushing sync.Mutex
	messages [][]byte
}