logger

package
v0.0.0-...-5252a31 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	*zap.Logger
	// contains filtered or unexported fields
}

func GetLogger

func GetLogger() *Logger

func NewLogger

func NewLogger(opts ...Options) *Logger

func (*Logger) AddCtx

func (l *Logger) AddCtx(ctx context.Context, field ...zap.Field) (context.Context, *zap.Logger)

添加额外上下文信息

func (*Logger) GetLevel

func (l *Logger) GetLevel() (level zapcore.Level)

func (*Logger) GetLoggerFromCtx

func (l *Logger) GetLoggerFromCtx(ctx context.Context) *zap.Logger

type Option

type Option struct {
	Development  bool
	LogFileDir   string
	AppName      string
	MaxSize      int    //文件大小阈值,超过阈值进行文件切割
	MaxBackups   int    // 文件备份数量
	MaxAge       int    // 文件最大保存时间
	Level        string // 级别
	CtxKey       string // 通过ctx传递log对象
	WriteFile    bool
	WriteConsole bool
}

type Options

type Options func(o *Option)

func WithAppName

func WithAppName(appName string) Options

func WithCtxKey

func WithCtxKey(ctxKey string) Options

func WithDevelopment

func WithDevelopment(development bool) Options

func WithLevel

func WithLevel(level string) Options

func WithMaxAge

func WithMaxAge(maxAge int) Options

func WithMaxBackups

func WithMaxBackups(maxBackups int) Options

func WithMaxSize

func WithMaxSize(maxSize int) Options

func WithWriteConsole

func WithWriteConsole(writeConsole bool) Options

func WithWriteFile

func WithWriteFile(writeFile bool) Options

func WithtLogFileDir

func WithtLogFileDir(logFileDir string) Options

Jump to

Keyboard shortcuts

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