bsc/log/async_file_writer_test.go
2020-05-20 12:19:39 +08:00

27 lines
430 B
Go

package log
import (
"io/ioutil"
"os"
"strings"
"testing"
)
func TestWriter(t *testing.T) {
w := NewAsyncFileWriter("./hello.log", 100)
w.Start()
w.Write([]byte("hello\n"))
w.Write([]byte("world\n"))
w.Stop()
files, _ := ioutil.ReadDir("./")
for _, f := range files {
fn := f.Name()
if strings.HasPrefix(fn, "hello") {
t.Log(fn)
content, _ := ioutil.ReadFile(fn)
t.Log(content)
os.Remove(fn)
}
}
}