logx

package
v0.0.0-...-afa1935 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogger

func GetLogger() *zap.Logger

func InitLog

func InitLog(setting *configx.Log)

InitLog log instance init

func NewLogger

func NewLogger(mod ...ModOptions) *zap.Logger

Types

type Logger

type Logger struct {
	Logger      *zap.Logger
	ZapSugar    *zap.SugaredLogger
	ZapConfig   zap.Config
	Opts        *Options `json:"opts"`
	Initialized bool
	Mux         sync.RWMutex
}

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

Debug package sugar of zap

func (*Logger) Debugf

func (l *Logger) Debugf(template string, args ...interface{})

Debugf package sugar of zap

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

Error package sugar of zap

func (*Logger) Errorf

func (l *Logger) Errorf(template string, args ...interface{})

Errorf package sugar of zap

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

Fatal package sugar of zap

func (*Logger) Fatalf

func (l *Logger) Fatalf(template string, args ...interface{})

Fatalf package sugar of zap

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

Info package sugar of zap

func (*Logger) Infof

func (l *Logger) Infof(template string, args ...interface{})

Infof package sugar of zap

func (*Logger) Init

func (l *Logger) Init()

func (*Logger) Panic

func (l *Logger) Panic(args ...interface{})

Panic package sugar of zap

func (*Logger) Panicf

func (l *Logger) Panicf(template string, args ...interface{})

Panicf package sugar of zap

func (*Logger) Warn

func (l *Logger) Warn(args ...interface{})

Warn package sugar of zap

func (*Logger) Warnf

func (l *Logger) Warnf(template string, args ...interface{})

Warnf package sugar of zap

func (*Logger) With

func (l *Logger) With(args ...interface{}) *Logger

With adds a variadic number of fields to the logging context. see https://github.com/uber-go/zap/blob/v1.10.0/sugar.go#L91

func (*Logger) WithConfig

func (l *Logger) WithConfig() zap.Option

WithConfig 根据配置文件更新 logger

type ModOptions

type ModOptions func(options *Options)

func SetAppName

func SetAppName(AppName string) ModOptions

func SetDebugFileName

func SetDebugFileName(DebugFileName string) ModOptions

func SetDevelopment

func SetDevelopment(Development bool) ModOptions

func SetErrorFileName

func SetErrorFileName(ErrorFileName string) ModOptions

func SetInfoFileName

func SetInfoFileName(InfoFileName string) ModOptions

func SetLevel

func SetLevel(Level zapcore.Level) ModOptions

func SetLogFileDir

func SetLogFileDir(LogFileDir string) ModOptions

func SetMaxAge

func SetMaxAge(MaxAge int) ModOptions

func SetMaxBackups

func SetMaxBackups(MaxBackups int) ModOptions

func SetMaxSize

func SetMaxSize(MaxSize int) ModOptions

func SetWarnFileName

func SetWarnFileName(WarnFileName string) ModOptions

type Options

type Options struct {
	Config        zap.Config
	AppName       string        //日志文件前缀
	Development   bool          //是否是开发模式
	Level         zapcore.Level //日志等级
	LogFileDir    string        //文件保存地方
	ErrorFileName string        //error日志文件后缀
	WarnFileName  string        //warn日志文件后缀
	InfoFileName  string        //info日志文件后缀
	DebugFileName string        //debug日志文件后缀
	MaxAge        int           //保存的最大天数
	MaxBackups    int           //最多存在多少个切片文件
	MaxSize       int           //日志文件小大(M)
}

Jump to

Keyboard shortcuts

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