Documentation ¶
Index ¶
- Constants
- func AccessLogFunc(log *Logger) gin.HandlerFunc
- func Bool(key string, val bool) zap.Field
- func Bools(key string, vars []bool) zap.Field
- func ByteString(key string, val []byte) zap.Field
- func ByteStrings(key string, vals [][]byte) zap.Field
- func Debug(msg string, fields ...zap.Field)
- func Duration(key string, val time.Duration) zap.Field
- func Durations(key string, vals []time.Duration) zap.Field
- func Err(err error) zap.Field
- func Error(msg string, fields ...zap.Field)
- func Errs(key string, errs []error) zap.Field
- func Fatal(msg string, fields ...zap.Field)
- func Float32(key string, val float32) zap.Field
- func Float32s(key string, vals []float32) zap.Field
- func Float64(key string, val float64) zap.Field
- func Float64s(key string, vals []float64) zap.Field
- func Info(msg string, fields ...zap.Field)
- func Int(key string, val int) zap.Field
- func Int16(key string, val int16) zap.Field
- func Int16s(key string, vals []int16) zap.Field
- func Int32(key string, val int32) zap.Field
- func Int32s(key string, vals []int32) zap.Field
- func Int64(key string, val int64) zap.Field
- func Int64s(key string, vals []int64) zap.Field
- func Int8(key string, val int8) zap.Field
- func Int8s(key string, vals []int8) zap.Field
- func Ints(key string, vals []int) zap.Field
- func Object(key string, val interface{}) zap.Field
- func Panic(msg string, fields ...zap.Field)
- func SetLogger(log *Logger)
- func Stack(key string) zap.Field
- func String(key string, val string) zap.Field
- func Strings(key string, val []string) zap.Field
- func Time(key string, val time.Time) zap.Field
- func Times(key string, vals []time.Time) zap.Field
- func Uint(key string, val uint) zap.Field
- func Uint16(key string, val uint16) zap.Field
- func Uint16s(key string, vals []uint16) zap.Field
- func Uint32(key string, val uint32) zap.Field
- func Uint32s(key string, vals []uint32) zap.Field
- func Uint64(key string, val uint64) zap.Field
- func Uint64s(key string, vals []uint64) zap.Field
- func Uint8(key string, val uint8) zap.Field
- func Uint8s(key string, vals []uint8) zap.Field
- func Uints(key string, vals []uint) zap.Field
- func Warn(msg string, fields ...zap.Field)
- type Config
- type EncoderType
- type Level
- type Logger
- func (l *Logger) Debug(msg string, fields ...zap.Field)
- func (l *Logger) Error(msg string, fields ...zap.Field)
- func (l *Logger) Fatal(msg string, fields ...zap.Field)
- func (l *Logger) Info(msg string, fields ...zap.Field)
- func (l *Logger) Panic(msg string, fields ...zap.Field)
- func (l *Logger) Warn(msg string, fields ...zap.Field)
- type Option
- func WithCaller() Option
- func WithConsoleEncoder() Option
- func WithDebugLevel() Option
- func WithErrorLevel() Option
- func WithFatalLevel() Option
- func WithInfoLevel() Option
- func WithJSONEncoder() Option
- func WithNoLock() Option
- func WithOutput(o io.Writer) Option
- func WithPanicLevel() Option
- func WithTimePattern(pattern string) Option
- func WithWarnLevel() Option
- type RotateWriter
Constants ¶
const ( // NameZapJSONLogger ZapJSONLogger NameZapJSONLogger = "zapJSONLogger" // NameConsoleLogger ZapConsoleLogger NameConsoleLogger = "zapConsoleLogger" // NameKey Name NameKey = "name" // StacktraceKey Stack StacktraceKey = "stack" // MessageKey Message MessageKey = "message" // LevelKey level LevelKey = "level" // TimeKey Time TimeKey = "time" // CallerKey Caller CallerKey = "caller" // DefaultTimePattern time pattern DefaultTimePattern = "2006-01-02 15:04:05" )
const string
Variables ¶
This section is empty.
Functions ¶
func ByteString ¶
ByteString constructs a field that carries UTF-8 encoded text as a []byte. To log opaque binary blobs (which aren't necessarily valid UTF-8), use Binary.
func ByteStrings ¶
ByteStrings constructs a field that carries a slice of []byte, each of which must be UTF-8 encoded text.
func Duration ¶
Duration constructs a field with the given key and value. The encoder controls how the duration is serialized.
func Float32 ¶
Float32 constructs a field that carries a float32. The way the floating-point value is represented is encoder-dependent, so marshaling is necessarily lazy.
func Float64 ¶
Float64 constructs a field that carries a float64. The way the floating-point value is represented is encoder-dependent, so marshaling is necessarily lazy.
func Object ¶
Object constructs a field with the given key and ObjectMarshaler. It provides a flexible, but still type-safe and efficient, way to add map- or struct-like user-defined types to the logging context. The struct's MarshalLogObject method is called lazily.
func Stack ¶
Stack constructs a field that stores a stacktrace of the current goroutine under provided key. Keep in mind that taking a stacktrace is eager and expensive (relatively speaking); this function both makes an allocation and takes about two microseconds.
func Time ¶
Time constructs a Field with the given key and value. The encoder controls how the time is serialized.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config for zap logger
type EncoderType ¶
type EncoderType int
EncoderType define
const ( // JSONEncoder Defined JSON encoder type for logger JSONEncoder EncoderType = iota // ConsoleEncoder Defined Console encoder type for logger ConsoleEncoder )
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger use zap logger
type Option ¶
type Option func(c *Config)
Option set the option to Config
func WithConsoleEncoder ¶
func WithConsoleEncoder() Option
WithConsoleEncoder set config encoder with ConsoleEncoder
func WithJSONEncoder ¶
func WithJSONEncoder() Option
WithJSONEncoder set config encoder with JSONEncoder
func WithTimePattern ¶
WithTimePattern set config timePattern
type RotateWriter ¶
type RotateWriter struct {
// contains filtered or unexported fields
}
RotateWriter writer
func NewRotateWriter ¶
func NewRotateWriter(fileName, pattern string) (*RotateWriter, error)
NewRotateWriter return new RotateWriter @fileName target file name @pattern time pattern