logger

package
v1.22.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2024 License: Zlib Imports: 15 Imported by: 4

Documentation

Index

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 Byte2

func Byte2(level int8, b []byte) string

func Configure

func Configure(config Config, opts ...Option) error

func Context added in v0.5.27

func Context() *zap.Logger

Context Deprecated: this function simply calls L.

func D added in v1.10.7

func D(msg, format string, args ...interface{})

func DObjectTo added in v1.8.101

func DObjectTo(o any) string

func DTraceId added in v1.8.101

func DTraceId(ctx context.Context) string

func Debug

func Debug(format string, args ...interface{})

func E added in v1.10.7

func E(msg, format string, args ...interface{})

E defines error log level.

func EObjectTo added in v1.8.101

func EObjectTo(o any) string

func ETraceId added in v1.8.101

func ETraceId(ctx context.Context) string

func Error

func Error(format string, args ...interface{})

Error defines error log level.

func F added in v1.10.7

func F(msg, format string, args ...interface{})

F defines fatal log level.

func Fatal

func Fatal(format string, args ...interface{})

Fatal defines fatal log level.

func I added in v1.10.7

func I(msg, format string, args ...interface{})

I defines info log level.

func IObjectTo added in v1.8.101

func IObjectTo(o any) string

func ITraceId added in v1.8.101

func ITraceId(ctx context.Context) string

func Info

func Info(format string, args ...interface{})

Info defines info log level.

func IsNDebug added in v1.10.11

func IsNDebug() bool

func L added in v1.8.68

func L() *zap.Logger

func N added in v1.10.7

func N(msg, format string, args ...interface{})

func NDebug

func NDebug(format string, args ...interface{})

NDebug *

正式环境,不输出日志

func NObjectTo added in v1.8.101

func NObjectTo(o any) string

func NTraceId added in v1.8.88

func NTraceId(ctx context.Context) string

func ObjectTo added in v1.8.101

func ObjectTo(o any) string

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.

func Recover added in v1.0.64

func Recover(callerSkip int, err interface{})

Recover defines error log level.

func SetNDebug added in v1.10.11

func SetNDebug(enable bool)

func SpecW added in v1.1.7

func SpecW(level int8, msg string, fields ...zapcore.Field)

func TraceId added in v1.8.88

func TraceId(ctx context.Context) string

func W added in v1.10.7

func W(msg, format string, args ...interface{})

W defines warn log level.

func WObjectTo added in v1.8.101

func WObjectTo(o any) string

func WTraceId added in v1.8.101

func WTraceId(ctx context.Context) string

func Warn

func Warn(format string, args ...interface{})

Warn defines warn log level.

func ZLog added in v1.0.40

func ZLog(info string) zap.Field

func ZLogf added in v1.0.40

func ZLogf(format string, args ...any) zap.Field

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 Decorate added in v1.8.101

type Decorate struct {
	S string
	E string
}

func (*Decorate) UseObject added in v1.8.101

func (d *Decorate) UseObject()

func (*Decorate) UseSlice added in v1.8.101

func (d *Decorate) UseSlice()

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 Option added in v1.10.5

type Option func(config *Config)

func WithHook added in v1.10.5

func WithHook(hook func(entry zapcore.Entry) error) Option

func WithNDebug added in v1.10.5

func WithNDebug(enabled bool) Option

func WithWriterLevel added in v1.20.10

func WithWriterLevel(level int8, w io.Writer) Option

func WithWriterType added in v1.20.10

func WithWriterType(writeType string, w io.Writer) Option

type WriterConfig added in v1.1.7

type WriterConfig struct {
	MinLevel  int8   `json:"minLevel" yaml:"minLevel" xml:"minLevel"`
	MaxLevel  int8   `json:"maxLevel" yaml:"maxLevel" xml:"maxLevel"`
	WriteType string `json:"type" yaml:"type" xml:"type"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL