mirror of
https://github.com/libp2p/go-libp2p-resource-manager.git
synced 2025-03-11 01:30:40 +08:00
add a timestamp to trace events (#34)
This commit is contained in:
parent
2e798e3cc5
commit
50387915ba
4
trace.go
4
trace.go
@ -47,6 +47,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type traceEvt struct {
|
type traceEvt struct {
|
||||||
|
Time string
|
||||||
Type string
|
Type string
|
||||||
|
|
||||||
Scope string `json:",omitempty"`
|
Scope string `json:",omitempty"`
|
||||||
@ -70,13 +71,14 @@ type traceEvt struct {
|
|||||||
FD int `json:",omitempty"`
|
FD int `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *trace) push(evt interface{}) {
|
func (t *trace) push(evt traceEvt) {
|
||||||
t.mx.Lock()
|
t.mx.Lock()
|
||||||
defer t.mx.Unlock()
|
defer t.mx.Unlock()
|
||||||
|
|
||||||
if t.done {
|
if t.done {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
evt.Time = time.Now().Format(time.RFC3339)
|
||||||
|
|
||||||
t.pend = append(t.pend, evt)
|
t.pend = append(t.pend, evt)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user