logger

package
v0.0.0-...-780cc0d Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

学习文档:

https://blog.csdn.net/wohu1104/article/details/107326794

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit

func Exit()

func InitLogger

func InitLogger(c Config)

InitLogger 设置日志级别 debug 可以打印出 info debug warn info 级别可以打印 warn info warn 只能打印 warn debug->info->warn->error

Types

type Config

type Config struct {
	Name          string
	Level         string
	IsDevelopment bool
}

type ModConfig

type ModConfig func(*ZapConfig)

func SetAppName

func SetAppName(AppName string) ModConfig

func SetDebugFileName

func SetDebugFileName(DebugFileName string) ModConfig

func SetDevelopment

func SetDevelopment(Development bool) ModConfig

func SetErrorFileName

func SetErrorFileName(ErrorFileName string) ModConfig

func SetInfoFileName

func SetInfoFileName(InfoFileName string) ModConfig

func SetLevel

func SetLevel(Level zapcore.Level) ModConfig

func SetLogFileDir

func SetLogFileDir(LogFileDir string) ModConfig

func SetMaxAge

func SetMaxAge(MaxAge int) ModConfig

func SetMaxBackups

func SetMaxBackups(MaxBackups int) ModConfig

func SetMaxSize

func SetMaxSize(MaxSize int) ModConfig

func SetWarnFileName

func SetWarnFileName(WarnFileName string) ModConfig

type ZapConfig

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

type ZapLogger

type ZapLogger struct {
	*zap.Logger
	sync.RWMutex
	Config *ZapConfig
	// contains filtered or unexported fields
}
var (
	ZapLog *ZapLogger
	Logger *zap.SugaredLogger
)

func NewZapLogger

func NewZapLogger(mod ...ModConfig) *ZapLogger

NewZapLogger 实例化日志

func (*ZapLogger) GetConfig

func (z *ZapLogger) GetConfig() *ZapConfig

Jump to

Keyboard shortcuts

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