begin, end

master
Charles Iliya Krempeaux 2021-02-10 11:40:40 -08:00
parent e7446423ca
commit abffb60501
3 changed files with 18 additions and 0 deletions

View File

@ -2,12 +2,15 @@ package flog
import (
"io"
"time"
)
type internalLogger struct {
prefix string
style string
begin time.Time
writer io.Writer
mutedAlert bool

View File

@ -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...)

View File

@ -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...)
}