Documentation
¶
Overview ¶
package log see: https://github.com/uber-go/zap demo:
_ = log.New(false)
defer log.Sync()
log.Info("this is a test message")
Index ¶
- func DPanic(msg string, fields ...zap.Field)
- func Debug(msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func Fatal(msg string, fields ...zap.Field)
- func Info(msg string, fields ...zap.Field)
- func Logger() *zap.Logger
- func New(development bool)
- func Panic(msg string, fields ...zap.Field)
- func SetLogger(log *zap.Logger) error
- func Sync() error
- func Warn(msg string, fields ...zap.Field)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Level is the minimum enabled logging level. Note that this is a dynamic
// level, so calling Config.Level.SetLevel will atomically change the log
// level of all loggers descended from this config.
Level zap.AtomicLevel `json:"level" yaml:"level"`
// Development puts the logger in development mode, which changes the
// behavior of DPanicLevel and takes stacktraces more liberally.
Development bool `json:"development" yaml:"development"`
// DisableCaller stops annotating logs with the calling function's file
// name and line number. By default, all logs are annotated.
// 调用 log方法 的文件名和行号
DisableCaller bool `json:"disableCaller" yaml:"disableCaller"`
// DisableStacktrace completely disables automatic stacktrace capturing. By
// default, stacktraces are captured for WarnLevel and above logs in
// development and ErrorLevel and above in production.
DisableStacktrace bool `json:"disableStacktrace" yaml:"disableStacktrace"`
// Sampling sets a sampling policy. A nil SamplingConfig disables sampling.
// 日志记录限流
// 每秒日志数量为Initial,如果超过,则每 Thereafter 条才记录
// 每秒计数器会重置
Sampling *zap.SamplingConfig `json:"sampling" yaml:"sampling"`
// Encoding sets the logger's encoding. Valid values are "json" and
// "console", as well as any third-party encodings registered via
// RegisterEncoder.
Encoder zapcore.Encoder
WriteSyncer zapcore.WriteSyncer
InitialFields map[string]interface{} `json:"initialFields" yaml:"initialFields"`
}
func NewDevelopment ¶
func NewDevelopment() Config
func NewProduction ¶
func NewProduction() Config
Click to show internal directories.
Click to hide internal directories.