基于 `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.

93 lines
2.4 KiB

2 years ago
  1. package log
  2. import (
  3. "go.uber.org/zap"
  4. "go.uber.org/zap/zapcore"
  5. )
  6. // 这里配置全局log字段
  7. const (
  8. KeyRequestID string = "requestID"
  9. KeyUsername string = "username"
  10. KeyWatcherName string = "watcher"
  11. )
  12. // 下面是zap包的别名
  13. // Field is an alias for the field structure in the underlying log frame.
  14. type Field = zapcore.Field
  15. // Level is an alias for the level structure in the underlying log frame.
  16. type Level = zapcore.Level
  17. var (
  18. // DebugLevel logs are typically voluminous, and are usually disabled in
  19. // production.
  20. DebugLevel = zapcore.DebugLevel
  21. // InfoLevel is the default logging priority.
  22. InfoLevel = zapcore.InfoLevel
  23. // WarnLevel logs are more important than Info, but don't need individual
  24. // human review.
  25. WarnLevel = zapcore.WarnLevel
  26. // ErrorLevel logs are high-priority. If an application is running smoothly,
  27. // it shouldn't generate any error-level logs.
  28. ErrorLevel = zapcore.ErrorLevel
  29. // PanicLevel logs a message, then panics.
  30. PanicLevel = zapcore.PanicLevel
  31. // FatalLevel logs a message, then calls os.Exit(1).
  32. FatalLevel = zapcore.FatalLevel
  33. )
  34. // Alias for zap type functions.
  35. var (
  36. Any = zap.Any
  37. Array = zap.Array
  38. Object = zap.Object
  39. Binary = zap.Binary
  40. Bool = zap.Bool
  41. Bools = zap.Bools
  42. ByteString = zap.ByteString
  43. ByteStrings = zap.ByteStrings
  44. Complex64 = zap.Complex64
  45. Complex64s = zap.Complex64s
  46. Complex128 = zap.Complex128
  47. Complex128s = zap.Complex128s
  48. Duration = zap.Duration
  49. Durations = zap.Durations
  50. Err = zap.Error
  51. Errors = zap.Errors
  52. Float32 = zap.Float32
  53. Float32s = zap.Float32s
  54. Float64 = zap.Float64
  55. Float64s = zap.Float64s
  56. Int = zap.Int
  57. Ints = zap.Ints
  58. Int8 = zap.Int8
  59. Int8s = zap.Int8s
  60. Int16 = zap.Int16
  61. Int16s = zap.Int16s
  62. Int32 = zap.Int32
  63. Int32s = zap.Int32s
  64. Int64 = zap.Int64
  65. Int64s = zap.Int64s
  66. Namespace = zap.Namespace
  67. Reflect = zap.Reflect
  68. Stack = zap.Stack
  69. String = zap.String
  70. Stringer = zap.Stringer
  71. Strings = zap.Strings
  72. Time = zap.Time
  73. Times = zap.Times
  74. Uint = zap.Uint
  75. Uints = zap.Uints
  76. Uint8 = zap.Uint8
  77. Uint8s = zap.Uint8s
  78. Uint16 = zap.Uint16
  79. Uint16s = zap.Uint16s
  80. Uint32 = zap.Uint32
  81. Uint32s = zap.Uint32s
  82. Uint64 = zap.Uint64
  83. Uint64s = zap.Uint64s
  84. Uintptr = zap.Uintptr
  85. Uintptrs = zap.Uintptrs
  86. )