zap

package
v1.0.33 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoggerLevel = zap.NewAtomicLevel()

LoggerLevel 动态设置 level 变量: 是全局参数,动态改变level后, 只影响改变时候处在的【作用域内的 logger】(不管是 父级 还是 兄弟 子孙 )

Functions

func TrunLevel

func TrunLevel(l string) zapcore.Level

TrunLevel level 转化为 zap 的 格式

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func DefaultLogger

func DefaultLogger() *Logger

DefaultLogger 默认 logger 配置

func NewLogger

func NewLogger(l *LoggerConf) *Logger

NewLogger 自定义一个 zap logger

func (*Logger) Debug

func (l *Logger) Debug(msg string)

func (*Logger) Debugf

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

func (*Logger) Error

func (l *Logger) Error(msg string)

func (*Logger) Errorf

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

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

func (*Logger) Fatalf

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

func (*Logger) GetZap added in v1.0.20

func (l *Logger) GetZap() *zap.Logger

func (*Logger) GetZapSugar added in v1.0.20

func (l *Logger) GetZapSugar() *zap.SugaredLogger

func (*Logger) Info

func (l *Logger) Info(msg string)

func (*Logger) Infof

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

func (*Logger) Named

func (l *Logger) Named(name string) logger2.Logger

Named 重命名 新建一个 子 logger 然后设置 名字

func (*Logger) Panic

func (l *Logger) Panic(msg string)

func (*Logger) Panicf

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

func (*Logger) Warn

func (l *Logger) Warn(msg string)

func (*Logger) Warnf

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

func (*Logger) With

func (l *Logger) With(key string, value interface{}) logger2.Logger

With 新建一个 子 logger 然后设置 filed 字段

type LoggerConf

type LoggerConf struct {
	Level      string `toml:"level" env:"SET_LOGGER_Level"`
	Format     string `toml:"format" env:"SET_LOGGER_FORMAT"`         // 日志格式:plain, json;
	WriteTo    TO     `toml:"writeto" env:"SET_LOGGER_WRITETO"`       // 写到: file  console  consolefile
	LogPath    string `toml:"logpath" env:"SET_LOGGER_LOGPATH"`       // 日志文件存放路径: 默认在 temp 目录
	LogFile    string `toml:"logfile" env:"SET_LOGGER_LOGFILE"`       // 日志文件名字: 默认为  default.log
	MaxSize    int    `toml:"maxsize" env:"SET_LOGGER_MAXSIZE"`       // 单个日志文件最大几M
	MaxBackups int    `toml:"magbackups" env:"SET_LOGGER_MAXBACKUPS"` // 最大保存多少个
	MaxAge     int    `toml:"maxage" env:"SET_LOGGER_MAXAGE"`         // 最多保存几天
}

func DefaultLoggerConfig

func DefaultLoggerConfig() *LoggerConf

func (*LoggerConf) AddStrTOFileName added in v1.0.19

func (l *LoggerConf) AddStrTOFileName(addstr string) string

AddStrTOFileName 文件由 a.log => a_addstr.log

func (*LoggerConf) GetLevel

func (l *LoggerConf) GetLevel() zapcore.Level

GetLevel 设置 日志级别

func (*LoggerConf) SetFormat

func (l *LoggerConf) SetFormat(format string) *LoggerConf

SetFormat 设置显示格式

func (*LoggerConf) SetLogFile

func (l *LoggerConf) SetLogFile(filename string) *LoggerConf

SetLogFile 设置日志文件名称

func (*LoggerConf) SetLogPath

func (l *LoggerConf) SetLogPath(path string) *LoggerConf

SetLogPath 设置日志路径

func (*LoggerConf) SetLogTo

func (l *LoggerConf) SetLogTo(station string) *LoggerConf

SetLogTo 设置日志发送到哪里

type TO

type TO string

func (TO) Str

func (t TO) Str() string

Jump to

Keyboard shortcuts

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