You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
412 B
18 lines
412 B
package log
|
|
|
|
import (
|
|
"go.uber.org/zap/zapcore"
|
|
"time"
|
|
)
|
|
|
|
func timeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
|
|
enc.AppendString(t.Format("2006-01-02 15:04:05.000"))
|
|
}
|
|
|
|
func autoDurationEncoder(d time.Duration, enc zapcore.PrimitiveArrayEncoder) {
|
|
//enc.AppendFloat64(float64(d) / float64(time.Millisecond))
|
|
if d > time.Minute {
|
|
d = d.Truncate(time.Second)
|
|
}
|
|
enc.AppendString(d.String())
|
|
}
|