基于 `zap` 包封装。除了实现 `Go` 日志包的基本功能外,还实现了很多高级功能 本包基于`github.com/tkestack/tke/pkg/util/log`裁剪
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

2 years ago
  1. package log
  2. import (
  3. "go.uber.org/zap/zapcore"
  4. "time"
  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 autoDurationEncoder(d time.Duration, enc zapcore.PrimitiveArrayEncoder) {
  10. //enc.AppendFloat64(float64(d) / float64(time.Millisecond))
  11. if d > time.Minute {
  12. d = d.Truncate(time.Second)
  13. }
  14. enc.AppendString(d.String())
  15. }