基于 `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.
|
|
package log
import ( "go.uber.org/zap" "go.uber.org/zap/zapcore" )
// 这里配置全局log字段
const ( KeyRequestID string = "requestID" KeyUsername string = "username" KeyWatcherName string = "watcher" )
// 下面是zap包的别名
// Field is an alias for the field structure in the underlying log frame.
type Field = zapcore.Field
// Level is an alias for the level structure in the underlying log frame.
type Level = zapcore.Level
var ( // DebugLevel logs are typically voluminous, and are usually disabled in
// production.
DebugLevel = zapcore.DebugLevel // InfoLevel is the default logging priority.
InfoLevel = zapcore.InfoLevel // WarnLevel logs are more important than Info, but don't need individual
// human review.
WarnLevel = zapcore.WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly,
// it shouldn't generate any error-level logs.
ErrorLevel = zapcore.ErrorLevel // PanicLevel logs a message, then panics.
PanicLevel = zapcore.PanicLevel // FatalLevel logs a message, then calls os.Exit(1).
FatalLevel = zapcore.FatalLevel )
// Alias for zap type functions.
var ( Any = zap.Any Array = zap.Array Object = zap.Object Binary = zap.Binary Bool = zap.Bool Bools = zap.Bools ByteString = zap.ByteString ByteStrings = zap.ByteStrings Complex64 = zap.Complex64 Complex64s = zap.Complex64s Complex128 = zap.Complex128 Complex128s = zap.Complex128s Duration = zap.Duration Durations = zap.Durations Err = zap.Error Errors = zap.Errors Float32 = zap.Float32 Float32s = zap.Float32s Float64 = zap.Float64 Float64s = zap.Float64s Int = zap.Int Ints = zap.Ints Int8 = zap.Int8 Int8s = zap.Int8s Int16 = zap.Int16 Int16s = zap.Int16s Int32 = zap.Int32 Int32s = zap.Int32s Int64 = zap.Int64 Int64s = zap.Int64s Namespace = zap.Namespace Reflect = zap.Reflect Stack = zap.Stack String = zap.String Stringer = zap.Stringer Strings = zap.Strings Time = zap.Time Times = zap.Times Uint = zap.Uint Uints = zap.Uints Uint8 = zap.Uint8 Uint8s = zap.Uint8s Uint16 = zap.Uint16 Uint16s = zap.Uint16s Uint32 = zap.Uint32 Uint32s = zap.Uint32s Uint64 = zap.Uint64 Uint64s = zap.Uint64s Uintptr = zap.Uintptr Uintptrs = zap.Uintptrs )
|