-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_test.go
38 lines (34 loc) · 918 Bytes
/
file_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package logkit
import (
log2 "log"
"testing"
"time"
)
func TestNewFileTarget(t *testing.T) {
ft := NewFileTarget()
ft.FilePath = "./temp"
log := NewLogKitByOptions(WithBuffer(1024), WithTargets(ft), WithCallStackDepth(0))
err := log.Open()
if err != nil {
log2.Fatal(err)
}
defer log.Close()
log.Error("Message, current time: %d",time.Now().Nanosecond())
// for i := 0; i <= 10000; i++ {
// log.Error("Message %d, current time: %d",i,time.Now().Nanosecond())
// }
}
func BenchmarkNewFileTarget(b *testing.B) {
ft := NewFileTarget()
ft.FilePath = "./temp"
log := NewLogKitByOptions(WithBuffer(1024), WithTargets(ft), WithCallStackDepth(0))
err := log.Open()
if err != nil {
log2.Fatal(err)
}
defer log.Close()
log.Error("Message, current time: %d",time.Now().Nanosecond())
// for i := 0; i <= 10000; i++ {
// log.Error("Message %d, current time: %d",i,time.Now().Nanosecond())
// }
}