begin, end
parent
e7446423ca
commit
abffb60501
|
@ -2,12 +2,15 @@ package flog
|
|||
|
||||
import (
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
||||
type internalLogger struct {
|
||||
prefix string
|
||||
style string
|
||||
|
||||
begin time.Time
|
||||
|
||||
writer io.Writer
|
||||
|
||||
mutedAlert bool
|
||||
|
|
|
@ -2,6 +2,7 @@ package flog
|
|||
|
||||
import (
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (receiver internalLogger) Begin(a ...interface{}) Logger {
|
||||
|
@ -16,6 +17,10 @@ func (receiver internalLogger) Begin(a ...interface{}) Logger {
|
|||
}
|
||||
|
||||
logger := receiver.Prefix(funcName)
|
||||
switch casted := logger.(type) {
|
||||
case *internalLogger:
|
||||
casted.begin = time.Now()
|
||||
}
|
||||
|
||||
a = append([]interface{}{"BEGIN"}, a...)
|
||||
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
package flog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (receiver internalLogger) End(a ...interface{}) {
|
||||
diff := time.Now().Sub(receiver.begin)
|
||||
|
||||
msg := fmt.Sprintf(" δt=%s", diff)
|
||||
|
||||
a = append([]interface{}{"END"}, a...)
|
||||
a = append(a, msg)
|
||||
|
||||
receiver.Debug(a...)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue