Documentation ¶
Index ¶
- Variables
- func DPanic(msg string, fields ...Field)
- func Debug(msg string, fields ...Field)
- func DebugEncodeLevel(lv zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
- func DefaultZapConfig() *zapcore.EncoderConfig
- func Error(msg string, fields ...Field)
- func Fatal(msg string, fields ...Field)
- func GetTraceID(ctx context.Context) string
- func Info(msg string, fields ...Field)
- func NewContext(ctx context.Context, l *Logger) context.Context
- func Panic(msg string, fields ...Field)
- func SetDefault(logger *Logger)
- func SetJupiter(logger *Logger)
- func SetTraceID(ctx context.Context, traceID string) context.Context
- func Warn(msg string, fields ...Field)
- type Config
- type Field
- func FieldAddr(value string) Field
- func FieldAddrAny(value interface{}) Field
- func FieldAid(value string) Field
- func FieldCode(value int32) Field
- func FieldColor(value string) Field
- func FieldCost(value time.Duration) Field
- func FieldErr(err error) Field
- func FieldErrKind(value string) Field
- func FieldEvent(value string) Field
- func FieldExtMessage(vals ...interface{}) Field
- func FieldHost(value string) Field
- func FieldIP(value string) Field
- func FieldKey(value string) Field
- func FieldKeyAny(value interface{}) Field
- func FieldMethod(value string) Field
- func FieldMod(value string) Field
- func FieldName(value string) Field
- func FieldReqAID(value string) Field
- func FieldReqHost(value string) Field
- func FieldStack(value []byte) Field
- func FieldStdMethod(value string) Field
- func FieldStringErr(err string) Field
- func FieldTID(value string) Field
- func FieldType(value string) Field
- func FieldValue(value string) Field
- func FieldValueAny(value interface{}) Field
- type Level
- type Logger
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( // String ... String = zap.String // Any ... Any = zap.Any // Int64 ... Int64 = zap.Int64 // Int ... Int = zap.Int // Int32 ... Int32 = zap.Int32 // Uint ... Uint = zap.Uint // Duration ... Duration = zap.Duration // Durationp ... Durationp = zap.Durationp // Object ... Object = zap.Object // Namespace ... Namespace = zap.Namespace // Reflect ... Reflect = zap.Reflect // Skip ... Skip = zap.Skip() // ByteString ... ByteString = zap.ByteString )
Functions ¶
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 DebugEncodeLevel ¶
func DebugEncodeLevel(lv zapcore.Level, enc zapcore.PrimitiveArrayEncoder)
DebugEncodeLevel ...
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 GetTraceID ¶ added in v0.4.3
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 SetDefault ¶ added in v0.6.1
func SetDefault(logger *Logger)
func SetJupiter ¶ added in v0.6.1
func SetJupiter(logger *Logger)
func SetTraceID ¶ added in v0.4.3
Types ¶
type Config ¶
type Config struct { // Dir 日志输出目录 Dir string // Name 日志文件名称 Name string // Level 日志初始等级 Level string // 日志初始化字段 Fields []zap.Field // 是否添加调用者信息 AddCaller bool // 日志前缀 Prefix string // 日志输出文件最大长度,超过改值则截断 MaxSize int MaxAge int MaxBackup int // 日志磁盘刷盘间隔 Interval time.Duration CallerSkip int Async bool Queue bool QueueSleep time.Duration Core zapcore.Core Debug bool EncoderConfig *zapcore.EncoderConfig // contains filtered or unexported fields }
Config ...
type Field ¶
Func ...
type Logger ¶
Func ...
func FromContext ¶ added in v0.4.3
func Named ¶ added in v0.6.1
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 ¶ added in v0.6.1
WithOptions clones the current Logger, applies the supplied Options, and returns the resulting Logger. It's safe to use concurrently.