-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.go
59 lines (51 loc) · 1.4 KB
/
log.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package ecRedis
import (
"fmt"
"github.com/ScottMansfield/nanolog"
"os"
)
var (
//LogClient nanolog.Handle
LogRec nanolog.Handle
LogDec nanolog.Handle
LogClient nanolog.Handle
nlogger func(nanolog.Handle, ...interface{}) error
)
func init() {
//LogClient = nanolog.AddLogger("%s All goroutine has finished. Duration is %s")
LogRec = nanolog.AddLogger("chunk id is %i, " +
"Client send RECEIVE req timeStamp is %s " +
"Client Peek ChunkId time is %s" +
"Client read ChunkId time is %s " +
"Client Peek chunkBody time is %s " +
"Client read chunkBody time is %s " +
"RECEIVE goroutine duration time is %s ")
LogDec = nanolog.AddLogger("DataStatus is %b, Decoding time is %s")
// cmd, reqId, Begin, duration, get/set req latency, rec latency, decoding latency
LogClient = nanolog.AddLogger("%s,%s,%i64,%i64,%i64,%i64,%i64,%b,%b")
}
func CreateLog(opts map[string]interface{}) {
path := opts["file"].(string) + "_bench.clog"
nanoLogout, err := os.Create(path)
if err != nil {
panic(err)
}
err = nanolog.SetWriter(nanoLogout)
if err != nil {
panic(err)
}
}
func FlushLog() {
if err := nanolog.Flush(); err != nil {
fmt.Println("log flush err")
}
}
func SetLogger(l func(nanolog.Handle, ...interface{}) error) {
nlogger = l
}
func nanoLog(handle nanolog.Handle, args ...interface{}) {
//if logger != nil {
fmt.Println("nanoLog argu 0 is", args[0])
nlogger(handle, args...)
//}
}