encoder.go 335 B

123456789101112131415
  1. package logs
  2. import (
  3. "time"
  4. "go.uber.org/zap/zapcore"
  5. )
  6. func timeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
  7. enc.AppendString(t.Format("2006-01-02 15:04:05.000"))
  8. }
  9. func milliSecondsDurationEncoder(d time.Duration, enc zapcore.PrimitiveArrayEncoder) {
  10. enc.AppendFloat64(float64(d) / float64(time.Millisecond))
  11. }