Documentation ¶
Index ¶
- Constants
- func Byte2(level int8, b []byte) string
- func Configure(config Config, opts ...Option) error
- func Context() *zap.Logger
- func D(msg, format string, args ...interface{})
- func DObjectTo(o any) string
- func DTraceId(ctx context.Context) string
- func Debug(format string, args ...interface{})
- func E(msg, format string, args ...interface{})
- func EObjectTo(o any) string
- func ETraceId(ctx context.Context) string
- func Error(format string, args ...interface{})
- func F(msg, format string, args ...interface{})
- func Fatal(format string, args ...interface{})
- func I(msg, format string, args ...interface{})
- func IObjectTo(o any) string
- func ITraceId(ctx context.Context) string
- func Info(format string, args ...interface{})
- func IsNDebug() bool
- func L() *zap.Logger
- func N(msg, format string, args ...interface{})
- func NDebug(format string, args ...interface{})
- func NObjectTo(o any) string
- func NTraceId(ctx context.Context) string
- func ObjectTo(o any) string
- func P(msg, format string, args ...interface{})
- func Panic(format string, args ...interface{})
- func Recover(callerSkip int, err interface{})
- func SetNDebug(enable bool)
- func SpecW(level int8, msg string, fields ...zapcore.Field)
- func TraceId(ctx context.Context) string
- func W(msg, format string, args ...interface{})
- func WObjectTo(o any) string
- func WTraceId(ctx context.Context) string
- func Warn(format string, args ...interface{})
- func ZLog(info string) zap.Field
- func ZLogf(format string, args ...any) zap.Field
- type Config
- type Decorate
- type FileConfig
- type Option
- type WriterConfig
Constants ¶
View Source
const ( // RecoverLevel () RecoverLevel = int8(-3) // NDebugLevel () NDebugLevel = int8(-2) DebugLevel = int8(zap.DebugLevel) InfoLevel = int8(zap.InfoLevel) // WarnLevel defines warn log level. WarnLevel = int8(zap.WarnLevel) // ErrorLevel defines error log level. ErrorLevel = int8(zap.ErrorLevel) // FatalLevel defines fatal log level. FatalLevel = int8(zap.FatalLevel) // PanicLevel defines panic log level. PanicLevel = int8(zap.PanicLevel) )
对外进行统一的封装
Variables ¶
This section is empty.
Functions ¶
func E ¶ added in v1.10.7
func E(msg, format string, args ...interface{})
E defines error log level.
func F ¶ added in v1.10.7
func F(msg, format string, args ...interface{})
F defines fatal log level.
func P ¶ added in v1.10.7
func P(msg, format string, args ...interface{})
P (format string, args ...interface{}) { defines panic log level.
func Panic ¶
func Panic(format string, args ...interface{})
Panic (format string, args ...interface{}) { defines panic log level.
Types ¶
type Config ¶
type Config struct { Level int8 `json:"level" yaml:"level" xml:"level"` NDebug bool `json:"nDebug" yaml:"nDebug" xml:"nDebug"` WriterEnabled bool `json:"writerEnabled" yaml:"writerEnabled" xml:"writerEnabled"` // 自己实现writer ConsoleEnabled bool `json:"console" yaml:"console" xml:"console"` FileEnabled bool `json:"fileEnabled" yaml:"fileEnabled" xml:"fileEnabled"` EncoderFormat string `json:"encoderFormat" yaml:"encoderFormat" xml:"encoderFormat"` FilePath string `json:"filePath" yaml:"filePath" xml:"filePath"` FileConfigs []FileConfig `json:"fileConfigs" yaml:"fileConfigs" xml:"fileConfigs"` WriterConfigs []WriterConfig `json:"writerConfigs" yaml:"writerConfigs" xml:"writerConfigs"` // contains filtered or unexported fields }
type FileConfig ¶ added in v1.0.62
type FileConfig struct { MinLevel int8 `json:"minLevel" yaml:"minLevel" xml:"minLevel"` MaxLevel int8 `json:"maxLevel" yaml:"maxLevel" xml:"maxLevel"` // Name is the name of the logfile which will be placed inside the directory Name string `json:"name" yaml:"name" xml:"name"` // MaxSize the max size in MB of the logfile before it's rolled MaxSize int `json:"maxSize" yaml:"maxSize" xml:"maxSize"` // MaxBackups the max number of rolled files to keep MaxBackups int `json:"backupNum" yaml:"backupNum" xml:"backupNum"` // MaxAge the max age in days to keep a logfile MaxAge int `json:"days" json:"days" xml:"days"` }
type WriterConfig ¶ added in v1.1.7
Click to show internal directories.
Click to hide internal directories.