Documentation ¶
Index ¶
- Constants
- Variables
- func Check(lvl Level, msg string) *zapcore.CheckedEntry
- func Core() zapcore.Core
- func DPanic(msg string, fields ...Field)
- func Debug(msg string, fields ...Field)
- func Error(msg string, fields ...Field)
- func Fatal(msg string, fields ...Field)
- func Info(msg string, fields ...Field)
- func Panic(msg string, fields ...Field)
- func SetLogger(logger *Logger)
- func Sugar() *zap.SugaredLogger
- func Sync() error
- func Warn(msg string, fields ...Field)
- type Config
- type Container
- type Field
- type Level
- type Logger
- type Option
- type SugaredLogger
Constants ¶
const ( // DebugLevel alias for zapcore.DebugLevel DebugLevel = zap.DebugLevel // InfoLevel alias for zapcore.InfoLevel InfoLevel = zap.InfoLevel // WarnLevel alias for zapcore.WarnLevel WarnLevel = zap.WarnLevel // ErrorLevel alias for zapcore.ErrorLevel ErrorLevel = zap.ErrorLevel // DPanicLevel alias for zapcore.DPanicLevel DPanicLevel = zapcore.DPanicLevel // PanicLevel alias for zapcore.PanicLevel PanicLevel = zap.PanicLevel // FatalLevel alias for zapcore.FatalLevel FatalLevel = zap.FatalLevel )
Variables ¶
var ( // Skip alias for zap.Skip() Skip = zap.Skip() // Binary alias for zap.Binary Binary = zap.Binary // Bool alias for zap.Bool Bool = zap.Bool // Boolp alias for zap.Boolp Boolp = zap.Boolp // ByteString alias for zap.ByteString ByteString = zap.ByteString // Complex128 alias for zap.Complex128 Complex128 = zap.Complex128 // Complex128p alias for zap.Complex128p Complex128p = zap.Complex128p // Complex64 alias for zap.Complex64 Complex64 = zap.Complex64 // Complex64p alias for zap.Complex64p Complex64p = zap.Complex64p // Float64 alias for zap.Float64 Float64 = zap.Float64 // Float64p alias for zap.Float64p Float64p = zap.Float64p // Float32 alias for zap.Float32 Float32 = zap.Float32 // Float32p alias for zap.Float32p Float32p = zap.Float32p // Int alias for zap.Int Int = zap.Int // Intp alias for zap.Intp Intp = zap.Intp // Int64 alias for zap.Int64 Int64 = zap.Int64 // Int64p alias for zap.Int64p Int64p = zap.Int64p // Int32 alias for zap.Int32 Int32 = zap.Int32 // Int32p alias for zap.Int32p Int32p = zap.Int32p // Int16 alias for zap.Int16 Int16 = zap.Int16 // Int16p alias for zap.Int16p Int16p = zap.Int16p // Int8 alias for zap.Int8 Int8 = zap.Int8 // Int8p alias for zap.Int8p Int8p = zap.Int8p // String alias for zap.String String = zap.String // Stringp alias for zap.Stringp Stringp = zap.Stringp // Uint alias for zap.Uint Uint = zap.Uint // Uintp alias for zap.Uintp Uintp = zap.Uintp // Uint64 alias for zap.Uint64 Uint64 = zap.Uint64 // Uint64p alias for zap.Uint64p Uint64p = zap.Uint64p // Uint32 alias for zap.Uint32 Uint32 = zap.Uint32 // Uint32p alias for zap.Uint32p Uint32p = zap.Uint32p // Uint16 alias for zap.Uint16 Uint16 = zap.Uint16 // Uint16p alias for zap.Uint16p Uint16p = zap.Uint16p // Uint8 alias for zap.Uint8 Uint8 = zap.Uint8 // Uint8p alias for zap.Uint8p Uint8p = zap.Uint8p // Uintptr alias for zap.Uintptr Uintptr = zap.Uintptr // Uintptrp alias for zap.Uintptrp Uintptrp = zap.Uintptrp // Reflect alias for zap.Reflect Reflect = zap.Reflect // Namespace alias for zap.Namespace Namespace = zap.Namespace // Stringer alias for zap.Stringer Stringer = zap.Stringer // Time alias for zap.Time Time = zap.Time // Timep alias for zap.Timep Timep = zap.Timep // Stack alias for zap.Stack Stack = zap.Stack // StackSkip alias for zap.StackSkip StackSkip = zap.StackSkip // Duration alias for zap.Duration Duration = zap.Duration // Durationp alias for zap.Duration Durationp = zap.Durationp // Object alias for zap.Object Object = zap.Object // Inline alias for zap.Inline Inline = zap.Inline // Any alias for zap.Any Any = zap.Any )
var ( // AddCallerSkip alias for zap.AddCallerSkip AddCallerSkip = zap.AddCallerSkip )
var NamedError = zap.NamedError
NamedError alias for zap.NamedError
Functions ¶
func Check ¶
func Check(lvl Level, msg string) *zapcore.CheckedEntry
Check returns a CheckedEntry if logging a message at the specified level is enabled. It's a completely optional optimization; in high-performance applications, Check can help avoid allocating a slice to hold fields.
func DPanic ¶
DPanic logs a message at DPanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
If the logger is in development mode, it then panics (DPanic means "development panic"). This is useful for catching errors that are recoverable, but shouldn't ever happen.
func Debug ¶
Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func Error ¶
Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func Fatal ¶
Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.
func Info ¶
Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
func Panic ¶
Panic logs a message at PanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.
The logger then panics, even if logging at PanicLevel is disabled.
func Sugar ¶
func Sugar() *zap.SugaredLogger
Sugar wraps the Logger to provide a more ergonomic, but slightly slower, API. Sugaring a Logger is quite inexpensive, so it's reasonable for a single application to use both Loggers and SugaredLoggers, converting between them on the boundaries of performance-sensitive code.
Types ¶
type Config ¶
type Config struct { Debug bool `mapstructure:"debug"` // 是否双写至文件控制日志输出到终端 Level string `mapstructure:"level"` // 日志初始等级,默认info级别 EnableAddCaller bool `mapsttructure:"enable_add_caller"` // 是否添加调用者信息,默认不加调用者信息 Writer string `mapstructure:"writer"` // 使用哪种Writer,可选[file|stdout],默认stdout CallerSkip int `mapstructure:"caller_skip"` // CallerSkip Fields []zap.Field // zapFields EncoderConfig *zapcore.EncoderConfig // 格式化配置 // contains filtered or unexported fields }
func DefaultConfig ¶
func DefaultConfig() *Config
func (*Config) AtomicLevel ¶
func (c *Config) AtomicLevel() zap.AtomicLevel
type Logger ¶
Logger ...
func Named ¶
Named adds a new path segment to the logger's name. Segments are joined by periods. By default, Loggers are unnamed.
func With ¶
With creates a child logger and adds structured context to it. Fields added to the child don't affect the parent, and vice versa.
func WithOptions ¶
WithOptions clones the current Logger, applies the supplied Options, and returns the resulting Logger. It's safe to use concurrently.
type Option ¶
type Option func(c *Container)
Option 可选项
func WithEnableAddCaller ¶
WithEnableAddCaller 是否添加行号,默认不添加行号